Skip to content
Prev Previous commit
fixup! fixup! fixup! fixup! fixup! separate tc for clarify on patch e…
…xpectations

Signed-off-by: Daeyeon Jeong <daeyeon.dev@gmail.com>
  • Loading branch information
daeyeon committed Apr 17, 2024
commit d7a556c021c1d57087420089398c991377858cc5
16 changes: 10 additions & 6 deletions test/parallel/test-inspector-exit-worker-in-wait-for-connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,36 @@
const common = require('../common');
common.skipIfInspectorDisabled();

const { parentPort, isMainThread, Worker } = require('node:worker_threads');
const { parentPort, workerData, Worker } = require('node:worker_threads');
if (!workerData) {
common.skipIfWorker();
}

const inspector = require('node:inspector');
const assert = require('node:assert');

// Refs: https://github.com/nodejs/node/issues/52467

let TIMEOUT = common.platformTimeout(5000);
if (common.isWindows) {
// Refs: https://github.com/nodejs/build/issues/3014
TIMEOUT = common.platformTimeout(15000);
}

// Refs: https://github.com/nodejs/node/issues/52467

(async () => {
if (isMainThread) {
if (!workerData) {
// worker.terminate() should terminate the worker and the pending
// inspector.waitForDebugger().
{
const worker = new Worker(__filename);
const worker = new Worker(__filename, { workerData: {} });
await new Promise((r) => worker.on('message', r));
await new Promise((r) => setTimeout(r, TIMEOUT));
worker.on('exit', common.mustCall());
await worker.terminate();
}
// process.exit() should kill the process.
{
const worker = new Worker(__filename);
const worker = new Worker(__filename, { workerData: {} });
await new Promise((r) => worker.on('message', r));
await new Promise((r) => setTimeout(r, TIMEOUT));
process.on('exit', (status) => assert.strictEqual(status, 0));
Expand Down