When using the --debug=6000 flag with the cluster module, the first debug port 6000 would be assigned to the cluster master, then the first worker would be assigned to 6001, then the second worker would be assigned to 6002, etc...
See https://strongloop.com/strongblog/whats-new-nodejs-v0-12-debugging-clusters/
However, when using the new --inspect=6000 flag with the cluster module, the cluster master process is assigned 6000 (which is correct) but the first worker is assigned 5859 (instead of the expected 6001), second worker is 5860 (instead of 6002), etc...
So this prevents us from changing the default debug ports for workers forked using the cluster module.
I tried messing with the settings on the cluster module by passing custom execArgv options such as: cluster.setupMaster({execArgv: ["--inspect=6001"]}) (I tried a few variations) but it doesn't appear to work.
That is because the cluster module currently uses process.debugPort as the base, which is not the port that the inspector uses.
You can use --debug-port=6000 --inspect=6000 (in that order) as a workaround for now.
if you use vs code to debug, you need to specify port and and "autoAttachChildProcesses": true in lanuch.json file. if you debug directly in DevTool ,you need to add a connection to corresponding port that in console.
Most helpful comment
That is because the cluster module currently uses
process.debugPortas the base, which is not the port that the inspector uses.You can use
--debug-port=6000 --inspect=6000(in that order) as a workaround for now.