diff --git a/lib/internal/cluster/master.js b/lib/internal/cluster/master.js index af421a04183ae8..839d6c4c313e9b 100644 --- a/lib/internal/cluster/master.js +++ b/lib/internal/cluster/master.js @@ -115,7 +115,7 @@ function createWorkerProcess(id, env) { for (var i = 0; i < execArgv.length; i++) { const match = execArgv[i].match( - /^(--inspect|--inspect-(brk|port)|--debug|--debug-(brk|port))(=\d+)?$/ + /^(--inspect|--inspect-(brk|port)|--debug|--debug-(brk|port))(=.*)?$/ ); if (match) { @@ -124,7 +124,7 @@ function createWorkerProcess(id, env) { ++debugPortOffset; } - execArgv[i] = match[1] + '=' + debugPort; + execArgv[i] = match[1] + '=' + process._debugHostname + ':' + debugPort; } } diff --git a/src/node.cc b/src/node.cc index c241f734b28901..010ae36251d93c 100644 --- a/src/node.cc +++ b/src/node.cc @@ -3361,6 +3361,11 @@ void SetupProcessObject(Environment* env, DebugPortSetter, env->as_external()).FromJust()); + READONLY_PROPERTY(process, + "_debugHostname", + OneByteString(env->isolate(), + debug_options.host_name().c_str())); + // define various internal methods env->SetMethod(process, "_startProfilerIdleNotifier", diff --git a/test/parallel/test-cluster-inspector-debug-port.js b/test/parallel/test-cluster-inspector-debug-port.js index 2b214c4ad26bd8..2c913ce140f286 100644 --- a/test/parallel/test-cluster-inspector-debug-port.js +++ b/test/parallel/test-cluster-inspector-debug-port.js @@ -28,6 +28,7 @@ if (cluster.isMaster) { fork(4, ['--inspect', `--debug-port=${debuggerPort}`]); fork(5, [`--inspect-port=${debuggerPort}`]); fork(6, ['--inspect', `--inspect-port=${debuggerPort}`]); + fork(7, [`--inspect=${common.localhostIPv4}:${debuggerPort}`]); } else { const hasDebugArg = process.execArgv.some(function(arg) { return /inspect/.test(arg);