diff --git a/atom/browser/node_debugger.cc b/atom/browser/node_debugger.cc index 5202462b695a4..fba5228bf5a6a 100644 --- a/atom/browser/node_debugger.cc +++ b/atom/browser/node_debugger.cc @@ -59,7 +59,8 @@ void NodeDebugger::Start() { } const char* path = ""; - if (inspector->Start(path, options, env_->inspector_host_port(), + if (inspector->Start(path, options, + std::make_shared(options.host_port), true /* is_main */)) DCHECK(env_->inspector_agent()->IsListening()); } diff --git a/spec/node-spec.js b/spec/node-spec.js index a6628c3113656..b4855ca2f5a4b 100644 --- a/spec/node-spec.js +++ b/spec/node-spec.js @@ -269,6 +269,34 @@ describe('node feature', () => { child.stdout.on('data', outDataHandler) }) + it('supports starting the v8 inspector with --inspect and a provided port', (done) => { + child = ChildProcess.spawn(process.execPath, ['--inspect=17364', path.join(__dirname, 'fixtures', 'module', 'run-as-node.js')], { + env: { + ELECTRON_RUN_AS_NODE: true + } + }) + + let output = '' + function cleanup () { + child.stderr.removeListener('data', errorDataListener) + child.stdout.removeListener('data', outDataHandler) + } + function errorDataListener (data) { + output += data + if (output.trim().startsWith('Debugger listening on ws://')) { + expect(output.trim()).to.contain(':17364', 'should be listening on port 17364') + cleanup() + done() + } + } + function outDataHandler (data) { + cleanup() + done(new Error(`Unexpected output: ${data.toString()}`)) + } + child.stderr.on('data', errorDataListener) + child.stdout.on('data', outDataHandler) + }) + it('does not start the v8 inspector when --inspect is after a -- argument', (done) => { child = ChildProcess.spawn(remote.process.execPath, [path.join(__dirname, 'fixtures', 'module', 'noop.js'), '--', '--inspect'])