Node: --inspect flag and cluster module - Debug port numbers not incrementing

Created on 21 Aug 2016  路  2Comments  路  Source: nodejs/node

  • Version: 6.4.0
  • Platform: Ubuntu
  • Subsystem: cluster

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.

inspector

Most helpful comment

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.

All 2 comments

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.

https://stackoverflow.com/questions/9691554/debugging-node-js-processes-with-cluster-fork/57743288#57743288

Was this page helpful?
0 / 5 - 0 ratings