Skip to content
This repository was archived by the owner on Apr 22, 2023. It is now read-only.

cluster: only assign debug port if in valid range. #14816

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions lib/cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,17 +307,19 @@ function masterInit() {
workerEnv = util._extend(workerEnv, env);
workerEnv.NODE_UNIQUE_ID = '' + id;

for (var i = 0; i < execArgv.length; i++) {
var match = execArgv[i].match(/^(--debug|--debug-brk)(=\d+)?$/);
if !(debug_port < 1024 || debug_port > 65535) { // If port in range according to node.cc:2903
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (debug_port >= 1024 && debug_port <= 65536) {

for (var i = 0; i < execArgv.length; i++) {
var match = execArgv[i].match(/^(--debug|--debug-brk)(=\d+)?$/);

if (match) {
execArgv[i] = match[1] + '=' + debugPort;
hasDebugArg = true;
if (match) {
execArgv[i] = match[1] + '=' + debugPort;
hasDebugArg = true;
}
}
}

if (!hasDebugArg)
execArgv = ['--debug-port=' + debugPort].concat(execArgv);
}

return fork(cluster.settings.exec, cluster.settings.args, {
env: workerEnv,
Expand Down