can --inspect be made to bind debug ports for child processes too?
See original GitHub issuerepro steps (I did this on linux and bash):
git clone https://github.com/AndrewJDR/inspect-on-forked-processes-doesnt-work
cd inspect-on-forked-processes-doesnt-work
npm i
npm start
This starts a child process using cluster.fork(). Note that debugger listens fine on the master process:
Debugger listening on ws://127.0.0.1:9229/1ffaac86-3b3f-4097-aa90-df1eba66b6f4
launching child
in the parent: 13039
in the child: 13049
And checking netstat shows that 9229 is indeed bound, which is good.
$ netstat -lnp | grep 9229
tcp 0 0 127.0.0.1:9229 0.0.0.0:* LISTEN 13039/node
However, no debugging port is bound for the child process. The output of ps, the --inspect-port=9230 argument would lead one to believe that a debugger port 9230 is available for the child process:
$ ps aux | grep ts-node
13027 pts/30 S+ 0:00 sh -c ts-node --inspect -F index.ts
13028 pts/30 Sl+ 0:00 node ~/Documents/src/inspect-on-forked-processes-doesnt-work/node_modules/.bin/ts-node --inspect -F index.ts
13039 pts/30 Sl+ 0:00 ~/.nvm/versions/node/v9.0.0/bin/node --inspect ~/Documents/src/inspect-on-forked-processes-doesnt-work/node_modules/ts-node/dist/_bin.js -F index.ts
13049 pts/30 Sl+ 0:00 ~/.nvm/versions/node/v9.0.0/bin/node ~/Documents/src/inspect-on-forked-processes-doesnt-work/node_modules/ts-node/dist/_bin.js --inspect --inspect-port=9230 ~/Documents/src/inspect-on-forked-processes-doesnt-work/index.ts
However, this is unfortunately not the case, looking at netstat output:
$ netstat -lnp | grep 9230
(.. nothing to see here ..)
Can others reproduce this? If so, can this please be addressed so that we can debug child processes properly?
Issue Analytics
- State:
- Created 6 years ago
- Comments:13 (9 by maintainers)
Top Results From Across the Web
How to debug a child process in Node and Gatsby.js with ...
Running --inspect-brk enables the inspector agent to bind to default host 127.0.0.1 and listen on the default port 9229 . Since multiple debuggers...
Read more >Impossible to debug node.js process that spawns child ...
What steps will reproduce the problem? 1. Have a node.js application/file that creates at least one child process - cp.fork('filepath') 2. Run with...
Read more >Use Node.js command line debugger on child process?
Yes. You have to spawn your process in a new port. There is a workaround to debug with clusters, in the same way...
Read more >How To Debug Node.js with the Built-In Debugger and ...
To solve this problem, developers use tools like a debugger, a program that allows developers to inspect their program as it runs. By...
Read more >Debug Node.js Apps using Visual Studio Code
With this setting, the debugger can attach to an already running process that was not started in debug mode. When using the processId...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I tried
process.execArgv.unshift(require('path').join(__dirname, 'bin.js'));and it didn’t work. This is the error I get:Basically it seems the child tries to bind to the same port as the parent.
The
ts-nodesubprocess has been killed with https://github.com/TypeStrong/ts-node/pull/536.