Skip to content

inspector: crash on debugger connection if JS session is already active #16852

Closed
@ofrobots

Description

@ofrobots

Found this on googleapis/cloud-debug-nodejs#356 originally.

// Flags: --inspect=9229
const inspector = require('inspector');
const session = new inspector.Session();
session.connect();

setInterval(() => { console.log('jello')}, 2000);

setTimeout(() => {
  require('child_process').spawn(process.execPath, [
    'inspect',
    'localhost:9229'
  ])
}, 1000);

Crashes with:

$ ./node_g --inspect ~/tmp/test/test.js
Debugger listening on ws://127.0.0.1:9229/8c72c164-5fc4-41b9-af56-8a8c4cf95cb7
For help see https://nodejs.org/en/docs/inspector
jello
Debugger attached.
/Users/ofrobots/src/node/out/Debug/node[35110]: ../src/inspector_agent.cc:347:void node::inspector::NodeInspectorClient::connectFrontend(node::inspector::InspectorSessionDelegate *): Assertion `(channel_) == (nullptr)' failed.
 1: node::Abort() [/Users/ofrobots/src/node/./node_g]
 2: node::(anonymous namespace)::DomainEnter(node::Environment*, v8::Local<v8::Object>) [/Users/ofrobots/src/node/./node_g]
 3: node::inspector::NodeInspectorClient::connectFrontend(node::inspector::InspectorSessionDelegate*) [/Users/ofrobots/src/node/./node_g]
 4: node::inspector::Agent::Connect(node::inspector::InspectorSessionDelegate*) [/Users/ofrobots/src/node/./node_g]
 5: node::inspector::InspectorIo::DispatchMessages() [/Users/ofrobots/src/node/./node_g]
 6: node::inspector::DispatchMessagesTask::Run() [/Users/ofrobots/src/node/./node_g]
 7: node::RunForegroundTask(v8::Task*) [/Users/ofrobots/src/node/./node_g]
 8: node::NodePlatform::FlushForegroundTasksInternal() [/Users/ofrobots/src/node/./node_g]
 9: node::FlushTasks(uv_async_s*) [/Users/ofrobots/src/node/./node_g]
10: uv__async_io [/Users/ofrobots/src/node/./node_g]
11: uv__io_poll [/Users/ofrobots/src/node/./node_g]
12: uv_run [/Users/ofrobots/src/node/./node_g]
13: node::Start(v8::Isolate*, node::IsolateData*, int, char const* const*, int, char const* const*) [/Users/ofrobots/src/node/./node_g]
14: node::Start(uv_loop_s*, int, char const* const*, int, char const* const*) [/Users/ofrobots/src/node/./node_g]
15: node::Start(int, char**) [/Users/ofrobots/src/node/./node_g]
16: main [/Users/ofrobots/src/node/./node_g]
17: start [/Users/ofrobots/src/node/./node_g]
[1]    35110 abort      ./node_g --inspect ~/tmp/test/test.js

This affects master, 9.x and 8.x.

/cc @nodejs/v8-inspector

Metadata

Metadata

Assignees

Labels

inspectorIssues and PRs related to the V8 inspector protocol

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions