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

Deactivating extensions do not always have enough time to clean up #11895

Closed
MSLaguana opened this issue Sep 12, 2016 · 1 comment
Closed

Deactivating extensions do not always have enough time to clean up #11895

MSLaguana opened this issue Sep 12, 2016 · 1 comment
Assignees
Labels
*question Issue represents a question, should be posted to StackOverflow (VS Code)

Comments

@MSLaguana
Copy link
Member

  • VSCode Version: 1.5.1
  • OS Version: Windows 10

Steps to Reproduce:

  1. Check out https://github.com/MSLaguana/vscode_deactivate_process_issue
  2. Run the extension in that project
  3. In the command palette, run "Spawn child process"
  4. Navigate to localhost:8080 and verify that a webserver is running
  5. In the command palette, run "Kill child process"
  6. Navigate to localhost:8080 and verify that no webserver is running; the cleanup command works correctly.
  7. In the command palette, run "Spawn child process", then close the experimental vscode instance
  8. Navigate to localhost:8080 and verify that the webserver is still running

We ran into this issue at microsoft/vscode-react-native#300 where during normal usage of the extension, we start a long-running child process which we want to clean up when the extension stops.

Specifically we are trying to run child_process.spawn("react-native.cmd", ...), which ends up creating an instance of cmd /c react-native.cmd that in turn creates the desired node cli.js .... We would like to make sure that descendant process is cleaned up, but because there is an extra layer of indirection we cannot simply call child_proc.kill() since that kills the cmd process but not the node process.

To work around this, on windows we use taskkill /T to kill the cmd process and all its descendants. This works fine during normal operation, but when the extension is terminating invoking taskkill is an async exec operation and so it does not complete. I also tried using exec-sync but that didn't help either.

Any suggestions on how to improve our behaviour here instead of leaking processes?

@jrieken jrieken removed their assignment Sep 13, 2016
@alexdima
Copy link
Member

alexdima commented Mar 2, 2017

Apologies for not answering here sooner, the deactivate method can return a promise and the extension host process will self-destruct when all the deactivate promises have completed or when 4 seconds have elapsed, whichever happens first.

@alexdima alexdima closed this as completed Mar 2, 2017
@alexdima alexdima added the *question Issue represents a question, should be posted to StackOverflow (VS Code) label Mar 2, 2017
@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*question Issue represents a question, should be posted to StackOverflow (VS Code)
Projects
None yet
Development

No branches or pull requests

3 participants