test: add regression test for worker terminate during TLA parent evaluation

Terminating a worker while it evaluates the parent module of a
top-level-await module used to abort the whole process with a V8 CHECK
failure (Check failed: !is_null()). Add a regression test that reproduces
the scenario from https://github.com/nodejs/node/issues/67550.

Refs: https://github.com/nodejs/node/issues/67550
PR-URL: https://github.com/nodejs/node/pull/67570
Refs: https://github.com/v8/v8/commit/be84cdeee94ee2574352cd6527d9a2f0bc0bea54
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Matteo Collina authored and Antoine du Hamel committed 2026-11-21 15:16:29 +01:00
1 parent fd53482db2
commit a9e2af0aad
3 files changed
+32

No files matched your search

+1
View File
@@ -0,0 +1 @@
await 0;
+6
View File
@@ -0,0 +1,6 @@
import { parentPort } from 'node:worker_threads';
import './terminate-worker-tla.mjs';
parentPort.postMessage('running');
const end = Date.now() + 5000;
while (Date.now() < end);
@@ -0,0 +1,25 @@
// Test: terminating a worker thread while it evaluates the parent module of a
// top-level-await module.
//
// worker.terminate() used to abort the whole process with a V8 CHECK failure
// (`Check failed: !is_null().`). See https://github.com/nodejs/node/issues/67550
// and the V8 cherry-pick be84cdeee94e.
import { mustCall } from '../common/index.mjs';
import assert from 'node:assert';
import { Worker } from 'node:worker_threads';
const worker = new Worker(
new URL('../fixtures/es-modules/tla/terminate-worker.mjs', import.meta.url),
);
worker.on('error', (err) => assert.fail(err));
// The worker posts 'running' at the top of the parent module body and then
// busy-waits. Terminating at that point used to abort the entire process via a
// V8 CHECK failure in `AsyncModuleExecutionFulfilled`; after the fix it
// terminates cleanly with exit code 1.
worker.on('message', mustCall(async (message) => {
assert.strictEqual(message, 'running');
assert.strictEqual(await worker.terminate(), 1);
}));