-
-
Notifications
You must be signed in to change notification settings - Fork 35.3k
Programatically setting the debug flag has no effects #12941
Copy link
Copy link
Closed
Labels
cliIssues and PRs related to the Node.js command line interface.Issues and PRs related to the Node.js command line interface.clusterIssues and PRs related to the cluster subsystem.Issues and PRs related to the cluster subsystem.feature requestIssues that request new features to be added to Node.js.Issues that request new features to be added to Node.js.help wantedIssues that need assistance from volunteers or PRs that need help to proceed.Issues that need assistance from volunteers or PRs that need help to proceed.inspectorIssues and PRs related to the V8 inspector protocolIssues and PRs related to the V8 inspector protocol
Metadata
Metadata
Assignees
Labels
cliIssues and PRs related to the Node.js command line interface.Issues and PRs related to the Node.js command line interface.clusterIssues and PRs related to the cluster subsystem.Issues and PRs related to the cluster subsystem.feature requestIssues that request new features to be added to Node.js.Issues that request new features to be added to Node.js.help wantedIssues that need assistance from volunteers or PRs that need help to proceed.Issues that need assistance from volunteers or PRs that need help to proceed.inspectorIssues and PRs related to the V8 inspector protocolIssues and PRs related to the V8 inspector protocol
Given the following code:
I get the following output on the console at runtime:
The reason for this is because the current code assumes that whatever flag present in execArgv will be the same as the one being passed to the master process, and therefore extracts the initial port from
process.debugPortinstead (ref: https://github.com/nodejs/node/blob/master/lib/internal/cluster/master.js#L98-L119). It also assumes that the first port will be used to debug the master, and automatically increment the port for the first worker. Finally, given the submitted code, one would arguably expect no increments to happen at all; in the actual use-case where I wish to make sure of this pattern, I use cluster with one and only one worker at a time, so re-using the same port would be perfectly fine.I would be more than happy to contribute a fix, but given the current behaviour and the fact that I don't know how I could actually distinguish programatic setup from the initial extraction of
execArgvpassed to the master process, I am having a bit of a hard time to figure out how to approach this issue. Suggestions more than welcome.