Skip to content

Commit ee09149

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

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

src/inspector_js_api.cc

+2-4
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;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
'use strict';
2+
const common = require('../common');
3+
4+
common.skipIfInspectorDisabled();
5+
6+
const { Session } = require('inspector');
7+
const { Worker, isMainThread, workerData } = require('worker_threads');
8+
9+
if (!workerData) {
10+
common.skipIfWorker();
11+
}
12+
13+
if (isMainThread) {
14+
new Worker(__filename, { workerData: {} });
15+
} else {
16+
const session = new Session();
17+
session.connectToMainThread();
18+
// Do not crash
19+
session.disconnect();
20+
}

0 commit comments

Comments
 (0)