help
help copied to clipboard
How does one pause a running process attached to with `node inspect`?
Details
I have a process running which has stalled on a remote machine and by far the easiest way to access it is using the cli debugger, node inspect -p <pid>
. I've been able to attach to the process without an issue, but I would like to know how to pause the process!
I can confirm that it is not paused, because attempting to run list
complains about the process not being paused. I would set a breakpoint, but I don't know where the process has stalled because I can't use list
. A nice catch 22.
Node.js version
14.17.1
Example code
No response
Operating system
ubuntu bullseye
Scope
debugging
Module and version
Not applicable.
You can use the devtools protocol and inspector
module to set breakpoints. It uses a websocket to connect to the process (with remote debugging) and you can tell it to pause, break where it is or pause on uncaught exceptions - e.g. https://chromedevtools.github.io/devtools-protocol/tot/Debugger/#method-pause - note this breaks the JavaScript part you can always connect to Node with something like lldb and debug the native bits too
I'm unable to use the devtools protocol to connect to this process, which runs on a remote server and is only accessible through a web-hosted terminal.
Using inspector
to set breakpoints is a good suggestion, except that I don't know where the process has stalled because I can't use list
.
I'm unable to use the devtools protocol to connect to this process, which runs on a remote server and is only accessible through a web-hosted terminal.
You can open the inspector locally on that computer and connect to it through a second node process on the same machine using the interface you have (web-hosted terminal)