Skip to content

Commit 6099d2d

Browse files
theanarkhdanielleadams
authored andcommittedJul 6, 2023
inspector: fix session.disconnect crash
PR-URL: #46942 Reviewed-By: Juan José Arboleda <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
1 parent ddf819f commit 6099d2d

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed
 

‎src/inspector_js_api.cc

+3-1
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,11 @@ class JSBindingsConnection : public AsyncWrap {
122122
new JSBindingsConnection(env, info.This(), callback);
123123
}
124124

125+
// See https://github.com/nodejs/node/pull/46942
125126
void Disconnect() {
127+
BaseObjectPtr<JSBindingsConnection> strong_ref{this};
126128
session_.reset();
127-
delete this;
129+
Detach();
128130
}
129131

130132
static void Disconnect(const FunctionCallbackInfo<Value>& info) {
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)
Please sign in to comment.