You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Restarting Debugger Failing to Kill Nodemon #56756
Please note also that if you quit VS Code after launching nodemon-hosted processes and don't stop them all manually in each process terminal with Cntrl-C you will find orphaned Node processes in Activity Monitor still running and consuming CPU after VS Code has stopped. These can of course be manually force-quit in Activity Monitor. I have requested an update for tasks to allow automatic process clean-up via a task (#65986). But "proper" support for nodemon such that Debug Stop and Debug Restart kill all relevant processes is the best solution assuming this is possible. For reference, I use compound of launch configs that look like below.
In my case, if I forget to manually kill the orphaned nodemon processes, they will eventually get stuck in a loop and start consuming 100% CPU. It's a major problem, and one that makes development using nodemon completely impractical.
Please find a way to automatically and reliably kill nodemon when debugging is stopped.
Wait a second - it actually looks like I have some success with the --exitcrash argument mentioned in #40430 (comment).
When that argument is specified, it actually looks like the nodemon process is killed when debugging is stopped or restarted 🎉
If that's really all it takes, the documentation here should probably be updated to mention that, instead of the current tip, which suggests that we must manually kill the orphaned nodemon processes.
However the next problem I have then is that 'Restart Debugging' generally opens a new integrated terminal (only sometimes reuses an existing terminal) and since I run a compound debug config (multiple processes) I end up with multiple abandoned terminals with last line showing "[nodemon] app crashed". This problem would be solved I believe by the ability to specify the presentation property for a launch config. (See #68123 (comment)). This would allow to specify presentation.panel as dedicated or new to choose if an existing terminal should be reused on 'Restart Debugging'. This issue is also relevant when using external terminals.
(As a side note, right now for me I can't use nodemon and integrated terminals at all (!) due to #71850 😟. But I hope that will get resolved not too long away.)
I have a different issue even while nodemon if I save a file the server restarts but after that 2 processes with node --inspect-brk=port keep running with high CPU usage.
They have a port that doesn't match with the debugger port shown in the terminal.
And even if I terminate those processes nodemon keeps running, indicating that those processes have no relation to the currently running server with nodemon.
Even if I quit VSCode those 2 processes keeps running. And there are only 2 processes never more than 2 or less than 2.
Attaching screenshots below:
You can see in the screenshot there are 3 node processes, the bottom one is the actual process which is running the server, which has quite low CPU usage.
The top 2 processes are using too much CPU.
Here is the screenshot of the integrated terminal showing the debugger port:
We since have a new debugger that handles child processes and trees like Nodemon in a more reliable way. Please let us know if you're still running into problems, and if so open an issue on that repo.
Activity
vscodebot commentedon Aug 19, 2018
(Experimental duplicate detection)
Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:
markm77 commentedon Jan 3, 2019
Please note also that if you quit VS Code after launching nodemon-hosted processes and don't stop them all manually in each process terminal with Cntrl-C you will find orphaned Node processes in Activity Monitor still running and consuming CPU after VS Code has stopped. These can of course be manually force-quit in Activity Monitor. I have requested an update for tasks to allow automatic process clean-up via a task (#65986). But "proper" support for nodemon such that Debug Stop and Debug Restart kill all relevant processes is the best solution assuming this is possible. For reference, I use compound of launch configs that look like below.
thomas-darling commentedon Feb 12, 2019
This really needs to be fixed, asap.
In my case, if I forget to manually kill the orphaned nodemon processes, they will eventually get stuck in a loop and start consuming 100% CPU. It's a major problem, and one that makes development using nodemon completely impractical.
Please find a way to automatically and reliably kill nodemon when debugging is stopped.
thomas-darling commentedon Feb 12, 2019
Wait a second - it actually looks like I have some success with the
--exitcrashargument mentioned in #40430 (comment).When that argument is specified, it actually looks like the nodemon process is killed when debugging is stopped or restarted 🎉
If that's really all it takes, the documentation here should probably be updated to mention that, instead of the current tip, which suggests that we must manually kill the orphaned nodemon processes.
markm77 commentedon May 22, 2019
Great posts Thomas Darling (@thomas-darling).
--exitcrashstops abandoned node processes for me.However the next problem I have then is that 'Restart Debugging' generally opens a new integrated terminal (only sometimes reuses an existing terminal) and since I run a compound debug config (multiple processes) I end up with multiple abandoned terminals with last line showing "[nodemon] app crashed". This problem would be solved I believe by the ability to specify the
presentationproperty for a launch config. (See #68123 (comment)). This would allow to specifypresentation.panelasdedicatedornewto choose if an existing terminal should be reused on 'Restart Debugging'. This issue is also relevant when using external terminals.(As a side note, right now for me I can't use nodemon and integrated terminals at all (!) due to #71850 😟. But I hope that will get resolved not too long away.)
rajatkantinandi commentedon Jan 6, 2020
I have a different issue even while nodemon if I save a file the server restarts but after that 2 processes with
node --inspect-brk=portkeep running with high CPU usage.They have a port that doesn't match with the debugger port shown in the terminal.
And even if I terminate those processes nodemon keeps running, indicating that those processes have no relation to the currently running server with nodemon.
Even if I quit VSCode those 2 processes keeps running. And there are only 2 processes never more than 2 or less than 2.
Attaching screenshots below:
You can see in the screenshot there are 3 node processes, the bottom one is the actual process which is running the server, which has quite low CPU usage.
The top 2 processes are using too much CPU.
Here is the screenshot of the integrated terminal showing the debugger port:
Launch config:
{ "name": "Launch Nodemon in Debug Mode", "type": "node", "request": "launch", "runtimeExecutable": "npx", "program": "${workspaceFolder}/build/app.js", "cwd": "${workspaceRoot}", "preLaunchTask": null, "runtimeArgs": [ "nodemon", "--nolazy", "--exitcrash" ], "env": { "NODE_ENV": "development", "NEW_RELIC_ENABLED": "false", }, "console": "integratedTerminal", "outFiles": [ "${workspaceRoot}/**/*.js" ], "sourceMaps": true, "protocol": "inspector", "restart": true }connor4312 commentedon Nov 5, 2020
We since have a new debugger that handles child processes and trees like Nodemon in a more reliable way. Please let us know if you're still running into problems, and if so open an issue on that repo.