Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--inspect flag and cluster module - Debug port numbers not incrementing #8201

Closed
jondubois opened this issue Aug 21, 2016 · 2 comments
Closed
Labels
inspector Issues and PRs related to the V8 inspector protocol

Comments

@jondubois
Copy link

jondubois commented Aug 21, 2016

  • 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.

@addaleax addaleax added the inspector Issues and PRs related to the V8 inspector protocol label Aug 21, 2016
@bnoordhuis
Copy link
Member

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.

cjihrig added a commit to cjihrig/node that referenced this issue Sep 14, 2016
This commit consolidates the debugging port used by the
inspector and Node's legacy debugger.

Fixes: nodejs#8201
PR-URL: nodejs#8386
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
ofrobots pushed a commit that referenced this issue Sep 19, 2016
Some tools are now relying on 9229 to be node.js "inspector" port (I
see Chrome extensions, some online blog posts, etc.) Also, having same
default port values for old and new protocols may lead to some
confusion, e.g. when tools are trying to autodiscover debuggable Node
instances.

This is a partial revert of 9f1f7e2. This commit preserves the fix for
issue #8201 bringing back the behavior that the old and new protocols
run on different ports.run on different ports.

PR-URL: #8550
Reviewed-By: ofrobots - Ali Ijaz Sheikh <ofrobots@google.com>
Reviewed-By: cjihrig - Colin Ihrig <cjihrig@gmail.com>
cjihrig added a commit to cjihrig/node that referenced this issue Oct 10, 2016
This commit adds a test for the debug port value in cluster
workers using the inspector debugger.

Refs: nodejs#8201
Refs: nodejs#8386
Refs: nodejs#8550
PR-URL: nodejs#8958
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com>
jasnell pushed a commit that referenced this issue Oct 10, 2016
This commit adds a test for the debug port value in cluster
workers using the inspector debugger.

Refs: #8201
Refs: #8386
Refs: #8550
PR-URL: #8958
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com>
@x343734282
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
inspector Issues and PRs related to the V8 inspector protocol
Projects
None yet
Development

No branches or pull requests

4 participants