-
Notifications
You must be signed in to change notification settings - Fork 30.7k
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
Allow reloading changes in workspace extensions #208698
Comments
@alexdima I believe it is not possible to unload and load a new version of extension even if the extension can be safely deactivated. Am I right? |
The problem is that we cannot guarantee an extension is deactivated safely because we can't detach it from all possible event emitters and then safely unload the code. So for example if an extension forgets a single subscription behind this could cause buggy behavior. We could invest in tracking all subscriptions created by an extension and disposing them ourselves, but there might remain other places like sockets, intervals, timeouts which we might miss. |
Isn't that the point of |
Yes, you're right! But my point is that we, as a platform, cannot guarantee safe unloading of all extensions. I agree that someone can write a good quality extension which keeps track of its disposables properly, but my argument is that someone might also write an extension where some disposables are not kept track of, which would lead to undefined behavior or unreproducible bugs. Other failure modes include: an extension patching the global Error.stack and forgetting to unpatch it (like some sourcemap support node modules), an extension using setInterval, an extension registering to a document change event, an extension loading a native node module which probably can't ever be unloaded etc. etc. All these leaks would make it that we hold on to the old code, to the old objects which might throw in unexpected ways. I also don't know if adding support for this would block ESM adoption, I'm not sure if someone can simply "reload" ESM modules. All in all, the bugs that would come out of this might not be worth it and a "Restart Extension Host" is so fast anyways. (takes a couple seconds) ... so maybe you'd also be happy with automatic Extension Host restarting? |
Testing #208184
It's my impression (which may not be correct) that extensions which export a
deactivate
function signal they can be gracefully deactivated in a running extension host. The selfhost test provider is one of these. It would be pretty nice if the extension was automatically deactivated and reloaded with the new code when it changes within a workspace.The text was updated successfully, but these errors were encountered: