How is Visual Studio Code debugger able to attach to a already running node process?
I simply used npm start
to run my node application and then use the VS Code "attach to process Id" launch configuration to start the debugger. I didn't had to start my application with --inspect
or --debug
flag. How is this actually working?
As can be found in the nodejs docs:
Node.js will also start listening for debugging messages if it receives a SIGUSR1 signal. (SIGUSR1 is not available on Windows.) In Node.js 7 and earlier, this activates the legacy Debugger API. In Node.js 8 and later, it will activate the Inspector API.
VS Code sends SIGUSR1
to the process. From the VS Code docs:
the debugger tries to attach to this process after having sent a USR1 signal. With this setting, the debugger can attach to an already running process that was not started in debug mode.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With