Skip to content
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 deactivate() doesn't call #47881

Closed
shawnfunke opened this issue Apr 14, 2018 · 2 comments · Fixed by microsoft/vscode-deploy-azure#202
Closed

Extension deactivate() doesn't call #47881

shawnfunke opened this issue Apr 14, 2018 · 2 comments · Fixed by microsoft/vscode-deploy-azure#202
Assignees
Labels
extension-host Extension host issues *question Issue represents a question, should be posted to StackOverflow (VS Code)

Comments

@shawnfunke
Copy link

  • VSCode Version: 1.22.2
  • OS Version: Windows 10.0.16299 Build 16299

Steps to Reproduce:

When creating an extension the "deactivate" function rarely calls in my case, sometimes it does call and most times it doesn't call, i couldn't find a pattern to it.

// Our event when vscode starts
export function activate(context: vscode.ExtensionContext): void {
	console.log("Activated Extension");
}

// Our event when vscode deactivates
export function deactivate(context: vscode.ExtensionContext): undefined {
	console.log("Deactivated Extension");

	return undefined;
}

Does this issue occur when all extensions are disabled?: Yes

@shawnfunke
Copy link
Author

After setting some break points it turns out that the deactivate function does run, but the console is already being destroyed, is this wanted?

@jrieken jrieken assigned alexdima and unassigned jrieken Apr 17, 2018
@alexdima
Copy link
Member

@7Flixs Extension deactivation always executes. But there are some things to consider:

  • The extensions run in a separate process, called the extension host process.
  • When closing a window, the renderer process goes down immediately.
  • The extension host process has at most 5 seconds to shut down, after which it will exit.
  • The vscode API will be unreliable at deactivation time, especially parts that are serviced by the renderer process (like e.g. openTextDocument, etc.)

The console output of the extension host is forwarded to the renderer process which then uses Chrome's console and also forwards it to the debugger, so it might also be unreliable.

All in all, deactivation is a time to quickly clean up OS resources, like e.g. kill other processes you have started. Sorry for all these limitations around deactivation, but I believe they lead to a good end user experience. i.e. the window closes as soon as x is closed and in at most 5 seconds the OS resources are reclaimed.

@alexdima alexdima added extensions Issues concerning extensions extension-host Extension host issues and removed extensions Issues concerning extensions labels Apr 17, 2018
@alexdima alexdima added the *question Issue represents a question, should be posted to StackOverflow (VS Code) label Apr 17, 2018
@vscodebot vscodebot bot locked and limited conversation to collaborators Jun 1, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
extension-host Extension host issues *question Issue represents a question, should be posted to StackOverflow (VS Code)
Projects
None yet
3 participants