vscode-csharp icon indicating copy to clipboard operation
vscode-csharp copied to clipboard

Leaking razor process

Open koliyo opened this issue 6 years ago • 18 comments

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

koliyo avatar Feb 13 '19 07:02 koliyo

@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 avatar Feb 13 '19 17:02 NTaylorMullen

@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.

dbaeumer avatar Feb 18 '19 11:02 dbaeumer

Hmm, interesting. The server should definitely be handling that exit notification successfully then. @koliyo does it leak every time?

FYI @david-driscoll

NTaylorMullen avatar Feb 19 '19 17:02 NTaylorMullen

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.

koliyo avatar Feb 20 '19 07:02 koliyo

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.

koliyo avatar Feb 20 '19 07:02 koliyo

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.

dbaeumer avatar Feb 20 '19 08:02 dbaeumer

@rchande / @akshita31 how do you guys ensure OmniSharp exits?

NTaylorMullen avatar Feb 20 '19 17:02 NTaylorMullen

@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

rchande avatar Feb 20 '19 21:02 rchande

Also faced this today randomly. I'm not even trying to use Razor or C#!

jonathan-contracts avatar Apr 06 '20 15:04 jonathan-contracts

Same here! Will try to provide more info if this becomes a regular issue.

tinanigro avatar Apr 26 '20 13:04 tinanigro

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.

awyl avatar May 25 '22 16:05 awyl

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):

image

jtsom avatar Jun 15 '22 00:06 jtsom

Is this issue even being looked at? Seem like a major problem, and no status update since February.

jtsom avatar Jul 01 '22 19:07 jtsom

A Month and a half later and nothing.....

jtsom avatar Aug 24 '22 20:08 jtsom

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.

akonyer avatar Aug 25 '22 20:08 akonyer

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.

lonix1 avatar Sep 08 '22 10:09 lonix1

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)

jtsom avatar Sep 08 '22 14:09 jtsom

I'm experiencing this today (mac m1 monterey 12.3.1). VS code 1.71.2

amplicity avatar Sep 30 '22 02:09 amplicity

My processes today (vscode is closed) macOS 12.6 vscode 1.72.2 omnisharp 1.25.0

Screenshot 2022-10-18 at 00 36 15

Really slows down intelisense too.

mikes-gh avatar Oct 17 '22 23:10 mikes-gh

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 avatar Jan 25 '23 00:01 allisonchou

@allisonchou vscode doesn't appear to recognise this update yet. Is this a main stream release?

mikes-gh avatar Jan 25 '23 16:01 mikes-gh

@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 image

dibarbet avatar Jan 25 '23 18:01 dibarbet

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.

mikes-gh avatar Jan 26 '23 16:01 mikes-gh