mirror of
https://github.com/stablyai/orca.git
synced 2026-10-31 09:07:40 +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>
30 lines
742 B
JavaScript
30 lines
742 B
JavaScript
import { parse, stringify } from 'devalue'
|
|
|
|
const reducers = {
|
|
Error: (value) =>
|
|
value instanceof Error && {
|
|
name: value.name,
|
|
message: value.message,
|
|
stack: value.stack,
|
|
cause: value.cause
|
|
}
|
|
}
|
|
|
|
const revivers = {
|
|
Error: ({ name, message, stack, cause }) => {
|
|
const error = new Error(message, cause === undefined ? undefined : { cause })
|
|
error.name = name
|
|
error.stack = stack
|
|
return error
|
|
}
|
|
}
|
|
|
|
// Preserves RegExp filters, cyclic test results, and Errors (e.g. a failed module fetch) across Bun/Node's JSON-only IPC.
|
|
export function encodeNodeRuntimeMessage(value) {
|
|
return stringify(value, reducers)
|
|
}
|
|
|
|
export function decodeNodeRuntimeMessage(text) {
|
|
return parse(text, revivers)
|
|
}
|