Skip to content

Commit c38daf7

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

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/inspector_js_api.cc

Lines changed: 1 addition & 1 deletion
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)
@@ -125,7 +126,6 @@ class JSBindingsConnection : public AsyncWrap {
125126

126127
void Disconnect() {
127128
session_.reset();
128-
delete this;
129129
}
130130

131131
static void Disconnect(const FunctionCallbackInfo<Value>& info) {
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)