Skip to content

NpmScriptRunner leaves NodeJs running (after test session) #5239

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

Closed
dstj opened this issue Sep 9, 2018 · 5 comments
Closed

NpmScriptRunner leaves NodeJs running (after test session) #5239

dstj opened this issue Sep 9, 2018 · 5 comments
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates feature-spa

Comments

@dstj
Copy link

dstj commented Sep 9, 2018

When running the functional tests of my dotnet core / angular app I noticed that the NodeJS processes are not stopped after my tests finishes. After 5 minutes after my tests completed, they are still there...

image

My NUnit OneTimeTearDown() also seems to be hanging when that happens. I'm guessing that's because I'm trying to dispose the web server in it.

image

I'm creating the server with _server = new WebApplicationFactory<Startup>() and calling both _server.Server?.Dispose(); and _server?.Dispose(); in the tests' teardown, just in case.

The culprit section in Startup is:

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

I went through the source a bit and in the NpmScriptRunner, there's an external npm process created that never seems to be killed and no reference to the process variable is maintained. Where is this process terminated? Could that be it?

More findings:

  • When running a single test by itself, the NodeJS processes are terminated, albeit after my test finishes
  • I tried reproducing on a newly created angular template project, no luck. It seems to only happen when multiple tests are ran...

Related issues:

@aspnet-hello aspnet-hello transferred this issue from aspnet/JavaScriptServices Dec 17, 2018
@aspnet-hello aspnet-hello added area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates feature-spa labels Dec 17, 2018
@dstj
Copy link
Author

dstj commented May 30, 2019

With the latest .NET Core (v2.2.204), I'm still having node.exe processes hanging after my functional tests complete.

I recently changed my tests startup to use a real web server (i.e. WebHost.CreateDefaultBuilder().UseStartup<Startup>()...) instead of the testing WebApplicationFactory. No change, node.exe still hangs.

I stumbled on this issue from the archived JavaScriptServices repo: aspnet/JavaScriptServices#270. @SteveSandersonMS, sorry the direct tag, but you were the one who closed that aspnet/JavaScriptServices#270 issue. My experience seems to show that it is not fixed, at the very least, not fully fixed...

@solvingproblemswithtechnology
Copy link

solvingproblemswithtechnology commented Jun 26, 2019

I'm having this issue con 2.2.300 too. I use the Readt template.

When I stop Visual Studio Debugging, the console keeps open with the title "npm" until I close it manually.

Looking at the code, I don't see any code to close npm. It should use IApplicationLifetime to close the process on Shutdown.

@mkArtakMSFT mkArtakMSFT added this to the spa-announcement milestone Aug 5, 2019
@mkArtakMSFT
Copy link
Member

We're closing this issue as this doesn't align with our long-term plans in this area. You can read more details about our vision for this area at #12890.

@ChristopherHaws
Copy link
Contributor

@mkArtakMSFT The middleware being referenced by this issue (UseAngularCliServer and UseReactDevelopmentServer) is part of Microsoft.AspNetCore.SpaServices.Extensions. The announcement you linked to says:

When ASP.NET Core 2.1 was released in May 2018, we responded to the change in standards by providing a newer and simpler way to integrate with the SPA frameworks' own toolchains. This new integration mechanism exists in the package Microsoft.AspNetCore.SpaServices.Extensions and remains the basis of our Angular and React project templates since ASP.NET Core 2.1.

The post does not mention Microsoft.AspNetCore.SpaServices.Extensions being deprecated. I believe this issue should be reopened, as I am having this issue as well after switching to the newer, recommended UseReactDevelopmentServer middleware.

@mkArtakMSFT
Copy link
Member

Seems this was a mistake. we will, however, track the issue as part of the referenced issue: #5204

@dotnet dotnet locked and limited conversation to collaborators Aug 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates feature-spa
Projects
None yet
Development

No branches or pull requests

5 participants