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

Restarting Debugger Failing to Kill Nodemon #56756

Closed
p-rk opened this issue Aug 19, 2018 · 7 comments
Closed

Restarting Debugger Failing to Kill Nodemon #56756

p-rk opened this issue Aug 19, 2018 · 7 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug debug Debug viewlet, configurations, breakpoints, adapter issues
Milestone

Comments

@p-rk
Copy link

p-rk commented Aug 19, 2018

  • VSCode Version: 1.26.1
  • OS Version: MAC OS 10.12.6

Steps to Reproduce:

  1. Start Debugger fn + F5
  2. Restart debugger from the debugger panel. It first crashes the app and then tries to restart but it gets timeout saying this

Cannot connect to runtime process, timeout after 10000 ms - (reason: Cannot connect to the target: connect ECONNREFUSED 127.0.0.1:29557).

When i see in the integrated terminal it show me up

[nodemon] app crashed - waiting for file changes before starting...

My launch configuration

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Launch via Nodemon",
      "type": "node",
      "request": "launch",
      "runtimeExecutable": "nodemon",
      "program": "${workspaceFolder}/api/api.js",
      "restart": true,
      "console": "integratedTerminal",
      "internalConsoleOptions": "neverOpen",
      "env":{"NODE_ENV":"development"},
      "timeout": 10000
    },
  ]
}

Does this issue occur when all extensions are disabled?: Yes

@vscodebot
Copy link

vscodebot bot commented Aug 19, 2018

(Experimental duplicate detection)
Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:

@weinand weinand added the debug Debug viewlet, configurations, breakpoints, adapter issues label Aug 20, 2018
@weinand weinand added this to the On Deck milestone Aug 20, 2018
@weinand weinand added the bug Issue identified by VS Code Team member as probable bug label Aug 20, 2018
@vscodebot vscodebot bot removed the new release label Aug 21, 2018
@markm77
Copy link

markm77 commented 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.

        {
            "type": "node",
            "request": "launch",
            "name": "Api",
            "runtimeExecutable": "nodemon",
            "cwd": "${workspaceFolder}/built",
            "program": "${workspaceFolder}/built/app.js",
            "restart": true,
            "env": {
                "NODE_ENV": "development",
                "DOMAIN": "xxx",
                "FORCE_COLOR": "10"
            },
            "port":9300,
            "runtimeArgs": [
                "--inspect-brk=9300"
            ],
            //"outputCapture": "std",
            "console": "integratedTerminal",
            "internalConsoleOptions": "neverOpen"
        },

@thomas-darling
Copy link

thomas-darling commented 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
Copy link

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.

@markm77
Copy link

markm77 commented May 22, 2019

Great posts @thomas-darling. --exitcrash stops 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 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.)

@rajatkantinandi
Copy link

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:

Screenshot 2020-01-06 at 12 37 25 PM

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:

Screenshot 2020-01-06 at 12 37 58 PM

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
Copy link
Member

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.

@github-actions github-actions bot locked and limited conversation to collaborators Dec 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug debug Debug viewlet, configurations, breakpoints, adapter issues
Projects
None yet
Development

No branches or pull requests

6 participants