mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
inspector: fix session.disconnect crash
PR-URL: https://github.com/nodejs/node/pull/46942 Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
This commit is contained in:
parent
115c9ac68d
commit
f543c054fc
@ -123,9 +123,11 @@ class JSBindingsConnection : public AsyncWrap {
|
||||
new JSBindingsConnection(env, info.This(), callback);
|
||||
}
|
||||
|
||||
// See https://github.com/nodejs/node/pull/46942
|
||||
void Disconnect() {
|
||||
BaseObjectPtr<JSBindingsConnection> strong_ref{this};
|
||||
session_.reset();
|
||||
delete this;
|
||||
Detach();
|
||||
}
|
||||
|
||||
static void Disconnect(const FunctionCallbackInfo<Value>& info) {
|
||||
|
20
test/parallel/test-inspector-connect-to-main-thread.js
Normal file
20
test/parallel/test-inspector-connect-to-main-thread.js
Normal file
@ -0,0 +1,20 @@
|
||||
'use strict';
|
||||
const common = require('../common');
|
||||
|
||||
common.skipIfInspectorDisabled();
|
||||
|
||||
const { Session } = require('inspector');
|
||||
const { Worker, isMainThread, workerData } = require('worker_threads');
|
||||
|
||||
if (!workerData) {
|
||||
common.skipIfWorker();
|
||||
}
|
||||
|
||||
if (isMainThread) {
|
||||
new Worker(__filename, { workerData: {} });
|
||||
} else {
|
||||
const session = new Session();
|
||||
session.connectToMainThread();
|
||||
// Do not crash
|
||||
session.disconnect();
|
||||
}
|
Loading…
Reference in New Issue
Block a user