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.js doesn't quit while stop debugging #2387

Closed
chesteryang opened this issue Jun 21, 2018 · 6 comments
Closed

Node.js doesn't quit while stop debugging #2387

chesteryang opened this issue Jun 21, 2018 · 6 comments

Comments

@chesteryang
Copy link

Environment data

dotnet --info output:
dotnet-info.txt

VS Code version:1.24.1
C# Extension version:1.15.2

The issue was filed to vscode first: microsoft/vscode#51933

Steps to reproduce

  1. create a new asp.net core react app. ( dotnet new ... ... )
  2. make it working.
  3. using default ".NET Core Launch (web)" to start debugging.
  4. Everytime starting debugging, after stop debugging, three or four more nodejs processes hanging in Task Manager. it quickly consumed all memory and make computer not responsive.
    nodejs

In process explorer this was found:

In debugging, process (id=13360) is a child process under dotnet.exe process (id=11188)

indebugging

Out of debugging, the process (id=13360) didn't get killed and its parent is gone.
outofdebugging

Expected behavior

It should work like Visual Studio 2017's debugging, while stopping debugging, all nodejs processes should be killed.

Actual behavior

nodjs processes are hanging in memory.

@gregg-miskelly
Copy link
Contributor

@chesteryang The debugger doesn't know anything about these node.js processes, so it will not kill them. This is true for both Visual Studio and VS Code.

Is your code spawning them?

@chesteryang
Copy link
Author

@gregg-miskelly
Yes, the project was created using dotnet new reactredux -n my-app.

in Startup.cs,

        app.UseSpa(spa =>
        {
            spa.Options.SourcePath = "ClientApp";

            if (env.IsDevelopment())
            {
                spa.UseReactDevelopmentServer(npmScript: "start");
            }
        });

in package.json
"scripts": {
"start": "rimraf ./build && react-scripts start",

This script will create those nodejs processes. But in Visual Studio 2017, default to IIS express, stop debugging will kill all of them.

@chesteryang
Copy link
Author

and in command line, if I use dotnet run to start app, I can use ctrl+c to shut down dotnet process and all its child processes.

@gregg-miskelly
Copy link
Contributor

So you can get the command line behavior if you set "console": "externalTerminal". 'integratedTerminal' would probably also work.

For a better fix: if I am tracking things down correctly, it sounds like you are running into a bug in the ASP.NET JavaScriptServices. There is an issue that sounds just like you describe here: aspnet/JavaScriptServices#270

Looking at what I think is their code to spawn node, they seem to be providing their parent pid for this purpose.

@gregg-miskelly
Copy link
Contributor

Should have also said: so I would probably suggest opening a new issue in that repo if you are running a build that should have that fix.

@chesteryang
Copy link
Author

@gregg-miskelly Okay, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants