Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: fix Worker termination in inspector.waitForDebugger #52527

Merged
merged 9 commits into from
May 13, 2024
Prev Previous commit
Next Next commit
fixup! fixup! fixup! fixup! separate tc for clarify on patch expectat…
…ions

Signed-off-by: Daeyeon Jeong <daeyeon.dev@gmail.com>
  • Loading branch information
daeyeon committed Apr 17, 2024

Verified

This commit was signed with the committer’s verified signature.
kbdharun K.B.Dharun Krishna
commit ee7472dd2c197e42aa16714811e2cc80f769bcd6
42 changes: 42 additions & 0 deletions test/parallel/test-inspector-exit-worker-in-wait-for-connection.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
'use strict';

const common = require('../common');
common.skipIfInspectorDisabled();

const { parentPort, isMainThread, Worker } = require('node:worker_threads');
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);
}

(async () => {
if (isMainThread) {
// worker.terminate() should terminate the worker and the pending
// inspector.waitForDebugger().
{
const worker = new Worker(__filename);
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);
await new Promise((r) => worker.on('message', r));
await new Promise((r) => setTimeout(r, TIMEOUT));
process.on('exit', (status) => assert.strictEqual(status, 0));
setImmediate(() => process.exit());
}
} else {
inspector.open(0, undefined, false);
parentPort.postMessage('open');
inspector.waitForDebugger();
}
})().then(common.mustCall());

This file was deleted.

Loading