Skip to content

Commit

Permalink
chore: serialize onUnhandledError error when rpc fails
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Feb 7, 2024
1 parent 029fca2 commit 95a90f1
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/vitest/src/runtime/rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ export function createRuntimeRpc(options: Pick<BirpcOptions<RuntimeRPC>, 'on' |
if (functionName === 'fetch' || functionName === 'transform' || functionName === 'resolveId')
message += ` with "${JSON.stringify(args)}"`

// JSON.stringify cannot serialize Error instances
if (functionName === 'onUnhandledError')
message += ` with "${args[0]?.message || args[0]}"`

throw new Error(message)
},
...options,
Expand Down

0 comments on commit 95a90f1

Please sign in to comment.