node/test/parallel/test-inspector-connect-to-main-thread.js
theanarkh f543c054fc
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>
2023-03-14 23:27:27 +00:00

21 lines
434 B
JavaScript

'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();
}