mirror of
https://github.com/stablyai/orca.git
synced 2026-10-30 16:47:34 +00:00
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>
25 lines
1.0 KiB
JavaScript
25 lines
1.0 KiB
JavaScript
import { parse, stringify } from 'devalue'
|
|
import { init, runBaseTests, setupEnvironment } from 'vitest/worker'
|
|
|
|
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({
|
|
post: (response) => send(response),
|
|
on: (callback) => process.on('message', callback),
|
|
off: (callback) => process.off('message', callback),
|
|
serialize: stringify,
|
|
deserialize: parse,
|
|
teardown: () => process.removeAllListeners('message'),
|
|
runTests: (state, traces) => runBaseTests('run', state, traces),
|
|
collectTests: (state, traces) => runBaseTests('collect', state, traces),
|
|
setup: setupEnvironment
|
|
})
|