vscode-csharp
vscode-csharp copied to clipboard
Leaking razor process
The csharp extension is leaking processes.
501 2957 1 0 8:22AM ?? 0:01.65 /Users/nils/.vscode/extensions/ms-vscode.csharp-1.17.1/.razor/rzls -lsp --logLevel None
Note: VS code is not running
Environment data
dotnet --info
output: Version: 2.2.103
VS Code version: 1.31.1
C# Extension version: 1.17.1
Mac OS Mojave
Steps to reproduce
Expected behavior
Proper cleanup of internal processes
Actual behavior
@dbaeumer Razor uses the LanguageClient
to turn on/off its LanguageServer. What's the best usage of LanguageClient to ensure that we dispose of the process when VSCode exits?
@NTaylorMullen the LanguageClient
offers a stop method. When called it send the shutdown
request to the server to tell the server process to shutdown. After receiving the shutdown response the clients sends the exit
notification to ask the server process to exit.
Hmm, interesting. The server should definitely be handling that exit notification successfully then. @koliyo does it leak every time?
FYI @david-driscoll
I don't think it happens every time.
A general suggestion would be not to rely completely on shutdown callbacks/notifications. You should also look at the POSIX setpgid
functionality, and how this can be used to bind child processes to the parent
See this snippet I am using in another project https://github.com/Microsoft/vscode-python/issues/3331#issuecomment-459278663
And from setpgid
man page
http://man7.org/linux/man-pages/man2/setpgid.2.html
If the termination of a process causes a process group to become
orphaned, and if any member of the newly orphaned process group is
stopped, then a SIGHUP signal followed by a SIGCONT signal will be
sent to each process in the newly orphaned process group. An
orphaned process group is one in which the parent of every member of
process group is either itself also a member of the process group or
is a member of a process group in a different session (see also
credentials(7)).
Not sure about similar functionality in Windows.
This is not isolated to any extension, such as omnisharp
and python
, but should be addressed systematically in VS Code. Which it does to some extent I guess.
For server's written in node this is addressed by passing the process id of the extension host to the server. Here we do this generically since we know how to start node. The Razor server uses a command to start the server. You could do the same and simply add an argument to the command that passes the process id. Our servers then check from time to time of that process still exists and if not exit themselves. This works under Linux, Mac and Windows.
@rchande / @akshita31 how do you guys ensure OmniSharp exits?
@NTaylorMullen We include it in our list of things to dispose when the extension is deactivated: https://github.com/OmniSharp/omnisharp-vscode/blob/master/src/omnisharp/extension.ts#L171
Also faced this today randomly. I'm not even trying to use Razor or C#!
Same here! Will try to provide more info if this becomes a regular issue.
On mac m1. Every time omnisharp start, it leaves behind a rzls
process. So if I restart omnisharp or reload vscode window or completely closed vscode, it leaves behind one rzls
each time.
This has been happening quite a while.
Currently on 1.38.3-beta.87-net6.0
.
This is a big issue. See the screenshot below - there are over a dozen of these abandoned rzls
processes running - even for older versions of the extension. This is with the latest version of the C# extension, and latest Insider version of VS Code (as of today):

Is this issue even being looked at? Seem like a major problem, and no status update since February.
A Month and a half later and nothing.....
I'm seeing this all the time. Most of the time I open and close VS Code I have rzls processes spun up and they hang out indefinitely, even after completely closing VSCode.
This MAJOR problem has been in existence for years. It's something I struggle with multiple times every day.
Related:
- https://github.com/OmniSharp/omnisharp-vscode/issues/5178
- https://github.com/OmniSharp/omnisharp-vscode/issues/2851
- https://github.com/OmniSharp/omnisharp-vscode/issues/5284
- https://github.com/OmniSharp/omnisharp-vscode/issues/3284
- https://github.com/OmniSharp/omnisharp-vscode/issues/3368
- https://github.com/OmniSharp/omnisharp-vscode/issues/4350
Possible diagnoses:
- https://github.com/Azure/bicep/issues/8171#issuecomment-1232322963
- https://github.com/OmniSharp/omnisharp-vscode/issues/4350#issuecomment-1163536551
The vscode team has had trouble reproducing this issue; I hope aggregating these will help them repro and find the root cause.
I don't know how they can't recreate it. Just open VSCode and open any .NET project. Quit VSCode and check the process list. rzls is still there. Keep opening and quitting VSCode, and for each time another rzls will spin up. And stay there until they are killed (killall rzls
on MacOS)
I'm experiencing this today (mac m1 monterey 12.3.1). VS code 1.71.2
My processes today (vscode is closed) macOS 12.6 vscode 1.72.2 omnisharp 1.25.0
Really slows down intelisense too.
Hi all! C# extension v1.25.4 was released earlier today which should address this problem. Please let us know if you continue to run into issues. Thanks, and happy coding!
@dibarbet Could you help close out this issue? (I don't have permissions.)
@allisonchou vscode doesn't appear to recognise this update yet. Is this a main stream release?
@allisonchou vscode doesn't appear to recognise this update yet. Is this a main stream release?
@mikes-gh
Yeah v1.25.4 was uploaded as the latest release to the gallery yesterday.
If VSCode isn't automatically updating for you, you could try explicitly requesting another version here
The short term report is rzls orphaned processes seems fixed on macOS. Thank you 🙏 . Saves me having to manually kill the processes which was a real pain.