From 351705bd35a2b52eaac778a7b7a500fac0c5415e Mon Sep 17 00:00:00 2001 From: OrcaWin Date: Mon, 26 Oct 2026 01:39:41 -0700 Subject: [PATCH] test(vitest): node-runtime worker exits when Vitest's IPC channel closes (#33848) A killed Vitest left its node-runtime worker running the rest of the file (still alive after 150s). Exit on 'disconnect' with process.exit captured before Vitest replaces it with a throwing guard. Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com> --- config/scripts/vitest-node-runtime-worker.mjs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/config/scripts/vitest-node-runtime-worker.mjs b/config/scripts/vitest-node-runtime-worker.mjs index 334292afd5b..31c125a3772 100644 --- a/config/scripts/vitest-node-runtime-worker.mjs +++ b/config/scripts/vitest-node-runtime-worker.mjs @@ -5,6 +5,10 @@ if (!process.send) { throw new Error('Node Vitest worker requires an IPC channel') } const send = process.send.bind(process) +// Vitest replaces process.exit with a throwing guard once a file runs, and the error then spins on the dead channel. +const exit = process.exit.bind(process) +// The pool stops workers by signal, so a closed channel means Vitest died; don't outlive it mid-file. +process.once('disconnect', () => exit(1)) // Preserve RegExp filters and cyclic test results across Bun/Node's JSON-only IPC boundary. init({