Skip to content

Commit 626e3ce

Browse files
committed
inspector: fix session.disconnect crash
1 parent 733ef4e commit 626e3ce

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

src/inspector_js_api.cc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ class JSBindingsConnection : public AsyncWrap {
6969
JSBindingsConnection* connection)
7070
: env_(env),
7171
connection_(connection) {
72+
connection_->Detach();
7273
}
7374

7475
void SendMessageToFrontend(const v8_inspector::StringView& message)
@@ -123,10 +124,7 @@ class JSBindingsConnection : public AsyncWrap {
123124
new JSBindingsConnection(env, info.This(), callback);
124125
}
125126

126-
void Disconnect() {
127-
session_.reset();
128-
delete this;
129-
}
127+
void Disconnect() { session_.reset(); }
130128

131129
static void Disconnect(const FunctionCallbackInfo<Value>& info) {
132130
JSBindingsConnection* session;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
'use strict';
2+
const common = require('../common');
3+
const { Session } = require('inspector');
4+
const { Worker, isMainThread, workerData } = require('worker_threads');
5+
6+
common.skipIfInspectorDisabled();
7+
8+
if (!workerData) {
9+
common.skipIfWorker();
10+
}
11+
12+
if (isMainThread) {
13+
new Worker(__filename, { workerData: {} });
14+
} else {
15+
const session = new Session();
16+
session.connectToMainThread();
17+
// Do not crash
18+
session.disconnect();
19+
}

0 commit comments

Comments
 (0)