Visual Studio 2019 Processes not shutting down, NodeJS issues
Asked Answered
P

5

29

I am working on a fresh install of Windows 10 Pro (10.0.18362) and trying to get Visual Studio 2019 setup and configured for .NET Core 3.1 Web Development but am running into several issues.

I created a default React.js ASP.NET Core Web Application and ran the project. Things seemed to be working alright, except that after updating JavaScript code the browser updates after a fairly long pause; things seem to be lagging.

After closing Visual Studio 2019 from the default Web App (no updates) there are several processes that seem to hang, and have to be shut down manually:

Visual Studio 2019 Processes

I have tried installing Visual Studio 2019 with the Node.js provided by the Visual Studio Installer, in addition to installing Node.js V12.4 and V13.6 manually with the same results.

Another problem: If I update the project from JavaScript to TypeScript using npx create-react-app client-app --typescript, Hot Updates stop working entirely. But after updating the JavaScript code and refreshing the browser things seem to update, so it does seem to be recompiling. I have tried debugging in Firefox and Chrome, both with the same results.

I am very hesitant to continue working with this install as I have had several issues when these processes. If these hang unexpectedly and are not shut down they will continue to use the old versions of the code and nothing that is done will update until the processes are shut down, causing complete insanity.

Could there a specific install procedure I need to perform as a workaround? Or am I possibly missing NuGet packages or Add-Ons? Since this is a fresh install of the operating system, are there Windows Features that I need to install? Or other configuration/permission changes that could be causing this?

Prior to this install, only projects created in Visual Studio 2017 seemed to work as expected. But I need to develop this site in .NET Core 3.0 and it looks like only Visual Studio 2019 is supported for that.

Update

After some messing around, it looks like Node is causing the problems. If I manually shut down the Node processes, then Visual Studio will finally shut down—but it leaves other processes like the VSCompiler and Consoles running. This happens even if I run Visual Studio as an administrator.

Should I install node before Visual Studio, or visa versa? Is there possibly some setup that I need to perform with Visual Studio or Node to get things working correctly?

Update 2

After not finding any fix I tried a complete reinstall of Windows, including a disk format, and then only installed Visual Studio and Node.js.

One interesting thing I found when doing this: I originally only installed Visual Studio and selected both the "Web Development" and "NodeJS Development". But when I tried to run a new .NET Core Web Application without any changes, I received an error saying that Node.js was not installed—even though I was able to find a node.exe in the MsBuilds folder under Visual Studio.

I completely uninstalled Visual Studio and all other components, installed Node.js, and then Visual Studio, but the problem still persists. Any time I try to run any kind of JavaScript using the SPA Templates, the Node.js processes don't shut down. If I kill the Node.js process then Visual Studio will finally shutdown, but it leaves the Console Window Host and VBCSCompiler running which have to be shut down manually.

I also tried creating a new .NET Core Web Application, except this time selecting the Angular Template and it works better: The Hot Reload works and it seems to run much faster. But the processes still don't shut down. The only difference is killing the Node.js processes doesn't let Visual Studio shutdown.

Update 3

Also not sure if this helps, but I tried setting the node.exe properties to "Run this program as an Administrator" to see if it happen to be a permission issue. This yielded the same results. I noticed that two windows will pop up, however: First a blank one, then the actual Angular server window.

I'm not sure if it's related, but when I tried to run the Angular Application again it looks like Angular is pointing at another (random) port than is set in the debug settings in the project.

One thing I did notice is that the usual Server Messages are not showing in the Output Window. It used to display the node.js messages such as "the server is running" and other compiler messages, but now it only displays the .NET output.

Update 4

Getting closer, I uninstalled Visual Studio and Node.js, then made sure to clean out any left over Visual Studio and node_modules folders from my AppData and User/Local directories, and then did a disk cleanup. Finally, I reinstalled Visual Studio—making sure to run the installer as Admin—and reinstalled Node.js.

I ran Visual Studio as an admin and created a new Angular App. Now, the Angular app works as expected, HMR works and things seem to run smoothly except that the processes still hang. The major difference is that killing the Microsoft Visual Studio 2019 process kills everything, whereas before it was leaving the VBSCCompiler, Node.js and consoles running.

When creating a React App things load fine. But, again, the HMR doesn't work and also leaves processes running. shutting down the main Visual Studio process seems to clean these up now too.

Prospector answered 16/1, 2020 at 18:27 Comment(6)
Is there possibly an antivirus interfering?Supercargo
@IanKemp No, I did a complete reinstall including a format and tried again without installing any other software other than VisualStudio 2019 and Node.js same resultsProspector
I would suggest opening a support case with Microsoft by using the feedback tool built into Visual Studio.Supercargo
@IanKemp I already did that, waiting on a replyProspector
I am getting a similar issue but I've noticed that it is not related to Visual Studio 2019 but rather to the version of .net core I'm targeting: Live reloading works in VS2019 with .netcore 2.1 And Angular versions 5.2.0/8/9.1 Live reloading fails in VS2019 with .netcore 3.1 And Angular 8/9.1 Tested in both Chrome and IE I am also left with loads of processes running like Node.js after closing Visual StudioBethune
I have the same problem with a react template application in Visual Studio Code. It's a pity they closed the support case you opened because of low priority.Scincoid
L
16

I'm afraid I don't have a fix but if anyone wants a quick way to kill all the errant node processes and speed things back up they can run:

taskkill /IM "node.exe" /F

I haven't had any issues executing this while VS is running.

enter image description here

Legere answered 28/2, 2020 at 13:45 Comment(2)
I'm just going to add this to my build process. VS2019 hangs for me often until I kill this.Circumambient
One problem with this method, it only kills the node processes and doesn't stop the VBCSCompiler.exe which will prevent any changes from being loaded until it shuts down, also it doesn't kill any of the conhost.exe processes that are also associated with the node processes. Do you know of any way to kill associated processes that are spawned from VS?Prospector
E
7

In Visual Studio 2019, go to Tools, Options, Debugging, General and towards the bottom there is a checkbox for Automatically close the console when debugging stops. It is unchecked by default on new versions of VS and if you look at your ASP.NET Core project properties you will see that it is a console project. So without the checkbox checked, the console does not automatically close.

The problem is that it is a hidden console so you can't see it to shut it down manually. If you check the box for closing the console automatically, then the consoles and node.js will stop running whenever you stop the debugger. Also in Options, there is a Node.Js Tools area that you may want to look at as well. It has a checkbox for Wait for input when process exits abnormally. If the console is hidden, there is no way for you to do input so that could hold the process open as well.

Another option, if you don't want to change any of the debugging options, is to go to your project properties > Debug and change the Launch settings for the IIS Express profile to Project instead of IIS Express. This will actually make the console / command prompt visible and when you are done debugging you can Ctrl-C to stop the debugger or when you hit stop the console will give you the message to Press any key to close this window . . .

Edmee answered 2/9, 2020 at 12:13 Comment(0)
I
0

I had the same issue with React SPA, this worked for me:

Tools -> Options -> Debugging -> General -> Enable JavaScript debugging for ASP.NET (Chrome, Edge and IE) (Visual Studio 2017 and 2019) <- unchecked

also the dropdown next to the play button:

Script Debugging -> disabled

Involved answered 9/7, 2020 at 12:41 Comment(0)
P
0

There are possibilities to run pre and post build tasks in Visual Studio. I would look for them in project settings. I use VSCode. So, if you follow the explanation below you'll be able to tackle the problem.

  1. Create a .bat file in your project root folder (for instance kill-node.bat) with the followwing content:
tasklist | find /i "node.exe" && taskkill /im node.exe /F || echo process "node.exe" not running.
  1. Add a pre-build-task executing the .bat file
  2. Add a post-build-task executing the .bat file
  3. Done! Now every single time you start debugging/redebugging your app, the .bat file kills all node-zombie instances. And ditto for your stopping dubug moment.

The VSCode guide:

  1. Perform step 1 of the algorithm above.
  2. Open the file tasks.json in .vscode folder and prepend at top of its tasks the new one:
{
  "label": "kill-node",
  "command": "kill-node.bat"
},
  1. Now alter the build task code (to activate our kill-node task at the pre-build time):
{
  "label": "build",
  "dependsOn": "kill-node",  // <<< extra string to run kill-node task prior to build task
  "command": "dotnet",
  //... the rest of build task code
}
  1. Open launch.json file and insert new string:
{
  "version": "0.2.0",
  "configurations": [
  {
    "name": ".NET Core Launch (web)",
    "type": "coreclr",
    "request": "launch",
    "preLaunchTask": "build",
    "postDebugTask": "kill-node",  //  <<< extra string to run kill-node on debug end
    //... the rest of launch.json file
  }
}
  1. That's it. Now you can no longer care of the node-zombie instances consuming your memory.
Petrinapetrine answered 29/6, 2021 at 6:53 Comment(0)
S
-2

This should be fixed in ASP.NET Core 5.0, try upgrading if possible.

Stott answered 20/11, 2020 at 5:59 Comment(3)
That was my hope but looks like it's still a problem with .NET 5 and Visual Studio V16.8.2. Just created a new default project, ran it and shut it down and those pesky processes were still runningProspector
Then it should be reported at github.com/dotnet/aspnetcoreStott
Was this actively fixed by some PR?Instillation

© 2022 - 2024 — McMap. All rights reserved.