You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Orphaned server processes when VS Code client process is killed #726
I've been trying to figure this out for a while, and I'm running out of ideas. I've read through this related thread: microsoft/vscode#35196
When I start the server from the client, I use a withProgress to monitor the progress. If close the VS Code client window right after the client start process begins, before client.onReady() returns, the server process is left orphaned/running.
vscode.window.withProgress({location: vscode.ProgressLocation.Notification,title: "my title",cancellable: false},(_progress,_token)=>{returnclient.onReady();});client.start();
My extension's deactivate function looks like this:
functiondeactivate(): Promise<void>|undefined{// ... other unrelated cleanup codeif(lspClient){returnlspClient.stop();}}
I've also made sure not to add the returned disposable from client.start() to the extension context subscriptions as noted in the linked thread.
If I wait for the client to fully start, then close the VS Code window, the server is shutdown fine. The problem is only when VS Code is closed right after the server begins to start. I see in the server logs that shutdown is called in this case, but exit is never called. It seems the VS Code client process is terminated before the response from shutdown is received, therefore exit is never called.
The server's shutdown method isn't doing anything time-consuming. My only other suspicion is that the server's startup functionality causes the incoming shutdown request's processing to be delayed, so while shutdown doesn't take long to return, it may be a while before it's called. I have no proof of this though, just a guess.
Is there anything else I can try from the client's perspective?
VS Code crashes / gets killed: servers need to protect themselves against this. This is why VS Code adds the process id of the process starting the server to the command line. It is also send in the initialize request. That allows a server to monitor the editor process and if it disappears exit gracefully.
We've noticed this behaviour as well and it leads to orphaned processes. The problem is that the code queues up an exit notification to send, but then closes the connection before the notification is actually sent. I've opened #776 to fix this issue.
Activity
dbaeumer commentedon Jan 11, 2021
There are two things:
dsherret commentedon Jun 22, 2021
We've noticed this behaviour as well and it leads to orphaned processes. The problem is that the code queues up an exit notification to send, but then closes the connection before the notification is actually sent. I've opened #776 to fix this issue.
bpringe commentedon Jun 23, 2021
Thanks for the fix!