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

Node process started via debugger is not killed when quitting VSCode #126211

Closed
jpike88 opened this issue Jun 14, 2021 · 11 comments
Closed

Node process started via debugger is not killed when quitting VSCode #126211

jpike88 opened this issue Jun 14, 2021 · 11 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug debug Debug viewlet, configurations, breakpoints, adapter issues insiders-released Patch has been released in VS Code Insiders on-release-notes Issue/pull request mentioned in release notes regression Something that used to work is now broken verified Verification succeeded
Milestone

Comments

@jpike88
Copy link

jpike88 commented Jun 14, 2021

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

  • VS Code Version: 1.57.0
  • OS Version: macOS Big Sur

Steps to Reproduce:

  1. Press CMD+Q to quit VSCode while an active debug session is running, using the node configuration.

Configuration looks like this:

{
				"type": "node",
				"request": "launch",
				"name": "Server",
				"windows": {
					"program": "${workspaceRoot}\\server\\dist\\app.js",
					"cwd": "${workspaceRoot}\\server"
				},
				"outputCapture": "std",
				"program": "${workspaceRoot}/server/dist/app.js",
				"cwd": "${workspaceRoot}/server",
				"env": {
					"FORCE_COLOR": "true",
					"LOCAL_DEVELOPMENT": "true"
				},
				"sourceMapPathOverrides": {
					"server/src/*": "${workspaceRoot}/server/src/*"
				},
				"resolveSourceMapLocations": ["!**/node_modules/**"]
			}
  1. Sometimes (about 30% of the time), I will later find that the above process had never been killed when quitting VSCode.

This bug is beyond frustrating, it makes using VSCode a chore. Please can this be fixed. Thanks

@jpike88
Copy link
Author

jpike88 commented Jun 14, 2021

an attempt to help workaround this issue (but not solving it):

I'm using a preLaunchTask that runs this script:

kill $(ps aux | grep dist/app.js -m1 | awk '{print $2}')

This ensures if I want to run the process next time I open VSCode, I don't need to check for and kill the previous process.

@weinand weinand added debug Debug viewlet, configurations, breakpoints, adapter issues bug Issue identified by VS Code Team member as probable bug labels Jun 14, 2021
@weinand
Copy link
Contributor

weinand commented Jun 14, 2021

I can reproduce: the debuggee node.js disappears, but the debug adapter's node.js stays around.
The same happens already when closing the debug session's window.

Workaround: stop the debug session before quitting VS Code (Shift-F5).

@weinand weinand added this to the June 2021 milestone Jun 14, 2021
@weinand weinand added the regression Something that used to work is now broken label Jun 14, 2021
@isidorn
Copy link
Contributor

isidorn commented Jun 23, 2021

@jpike88 thanks a lot for creating this great issue 👏
I was listening on lifecycleService.onDidShutdown to shutdown the node sesion, now I changed to lifecycleService.onWillShutdown which happens a bit earlier and I am blocking the VSCode shutdown until I send the proper disconnect request - this should be fine since sending the request should not take a long time. I tried this out and works nicely on my machine. Though it would be great if you can also try it out with VS Code insiders from tomorrow and let us know how it goes.

fyi @bpasero for lifecycleService usage

@bpasero
Copy link
Member

bpasero commented Jun 23, 2021

That sounds good to me:

  • onBeforeShutdown: can be used if you need to prevent the shutdown
  • onWillShutdown: can be used to join the shutdown with a long running op
  • onDidShutdown: cannot be async and should typically not be used

Note: in web, there is no long running shutdown so you might see a warning appearing.

@isidorn
Copy link
Contributor

isidorn commented Jun 23, 2021

@bpasero great! Maybe we should create a debt issue to go through all the onDidShutdown usage and change to onWillShutdown if possible. What do you think?

@bpasero
Copy link
Member

bpasero commented Jun 23, 2021

I think I made that pass some time ago when I added these distinct events, but yeah wouldn't hurt.

@weinand
Copy link
Contributor

weinand commented Jun 23, 2021

@isidorn what had changed in VS Code that resulted in this breakage?

@isidorn
Copy link
Contributor

isidorn commented Jun 23, 2021

@weinand timing. We did not change code on our end. I am not sure when this broke exactly.

@weinand
Copy link
Contributor

weinand commented Jun 23, 2021

So your use of the lifecycleService.onDidShutdown was not a recent change?

@isidorn
Copy link
Contributor

isidorn commented Jun 23, 2021

Correct. It was like that for more than a year.

@connor4312
Copy link
Member

I've had trouble reproducing this on stable, and also didn't see it on Insiders. @jpike88 please let us know if you see this happening on Insiders.

@isidorn isidorn added the on-release-notes Issue/pull request mentioned in release notes label Jul 2, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Aug 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug debug Debug viewlet, configurations, breakpoints, adapter issues insiders-released Patch has been released in VS Code Insiders on-release-notes Issue/pull request mentioned in release notes regression Something that used to work is now broken verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

6 participants
@bpasero @weinand @isidorn @connor4312 @jpike88 and others