mirror of
https://github.com/stablyai/orca.git
synced 2026-10-31 00:57:45 +00:00
devalue rejects Error objects, so when a NODE_RUNTIME_INCLUDE test file failed to load, the pool's send() threw DevalueError and the run ended without a summary. Give both ends of the IPC channel one codec with a matching Error reducer/reviver (name, message, stack, cause) so the load failure reaches the reporter as a normal FAIL. Fixes #29854 Co-authored-by: Neil <neil@stably.ai>
27 lines
1.0 KiB
JavaScript
27 lines
1.0 KiB
JavaScript
import { init, runBaseTests, setupEnvironment } from 'vitest/worker'
|
|
import {
|
|
decodeNodeRuntimeMessage,
|
|
encodeNodeRuntimeMessage
|
|
} from './vitest-node-runtime-ipc-codec.mjs'
|
|
|
|
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))
|
|
|
|
init({
|
|
post: (response) => send(response),
|
|
on: (callback) => process.on('message', callback),
|
|
off: (callback) => process.off('message', callback),
|
|
serialize: encodeNodeRuntimeMessage,
|
|
deserialize: decodeNodeRuntimeMessage,
|
|
teardown: () => process.removeAllListeners('message'),
|
|
runTests: (state, traces) => runBaseTests('run', state, traces),
|
|
collectTests: (state, traces) => runBaseTests('collect', state, traces),
|
|
setup: setupEnvironment
|
|
})
|