-
Notifications
You must be signed in to change notification settings - Fork 30.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extension: During deactivate, globalState.update promises are immediately canceled #144118
Comments
Documentation at https://code.visualstudio.com/api/references/activation-events#Start-up may be relevant:
|
Thanks, @gjsjohnmurray , for the documentation link. However, I don't believe that is the issue here. The |
Maybe some clues in #122825 (comment) |
Yep, that does look relevant. It would be unfortunate if the entire vscode API was non-functional during Maybe there are two action items here:
As a workaround, folks can avoid using Related but probably a separate thread from all of this: I first started to implement cleanup tasks by returning I could help contribute some of these changes, although I could use some high level pointers on what and where. |
See #140697 (comment) and following. |
@alexdima should it be possible to run long running operations in the |
@bpasero We currently don't keep the renderer process running longer to wait for the extension host to shut down. The comment at #122825 (comment) is still accurate. We can, however, decide to revisit this past decision. But this would change how reloading works, how opening a folder works, etc. If we decide to keep the renderer up and running to service API calls, this might result in constant 5-6s delays to all these operations. I agree that Regarding vscode/src/vscode-dts/vscode.d.ts Line 1491 in 98c97ab
vscode/src/vscode-dts/vscode.d.ts Line 6573 in 98c97ab
|
I think invalidating the API and special errors in selected places makes sense to me. Failing to update/persist state during shutdown is an evergreen and a better error would certain improve things. |
Invalidation/special errors sounds great! Let me know if you're interested in help here. @alexdima I'm embarrassed that I missed the existing documentation about the non-async behavior of
If you're inclined, I think Separately: I wouldn't ask for a revisit on delaying the renderer shutdown. I love the responsiveness there. What I should have asked in my earlier post is: Is the storage API's implementation inherently dependent on the renderer process, or is it just that the extension driving the API is hosted in that process? If it's the latter, what about these ideas:
|
This comment was marked as resolved.
This comment was marked as resolved.
@andreamah this issue may be relevant to #128138 which you commented on and reopened today. I couldn't add this comment there because when reopening it you forgot to unlock it. |
oh, nice catch! thanks for letting me know! |
Yes, all vscode async API should be avoided during deactivate. Most async API is serviced by the renderer process, which might have already disappeared. For critical things, like making storing critical data, we suggest a pattern of auto-saving after a delay, and doing OS resource cleanup during deactivate (killing spawned processes, shutting down spawned VMs, etc.). |
The described behavior is how it is expected to work. If you disagree, please explain what is expected and what is not in more detail. See also our issue reporting guidelines. Happy Coding! |
@alexdima Thank you very much. Although I humbly suggest that this critical information be added to the official documentation about an extension disactivate function. (Because a vast majority of cleanup tasks intended by extension developers might be async procedures!) |
@boltex Would you please create a PR against https://github.com/microsoft/vscode-docs which backs our website? |
Issue Type: Bug
Minimal repro here, which consists of the default
yo code
-created extension with the changes summarized below:Repro Steps
deactive
, delete a key fromcontext.globalState
, and return the resulting promise.Expected: As long as the promise finishes within 5 seconds, the operation will complete.
Actual: The promise is canceled. In the repro shown here, the message
globalState.update failed with Canceled: Canceled
is emitted. The next time the extension is run, the extension printsPre-existing keys: [test]
, verifying that the key was not removed.VS Code version: Code 1.64.2 (f80445a, 2022-02-09T22:02:28.252Z)
OS version: Windows_NT x64 10.0.19044
Restricted Mode: No
System Info
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
rasterization: enabled
skia_renderer: enabled_on
video_decode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
Extensions (35)
(2 theme extensions excluded)
A/B Experiments
The text was updated successfully, but these errors were encountered: