···7373 if (functionName === 'fetch' || functionName === 'transform' || functionName === 'resolveId')
7474 message += ` with "${JSON.stringify(args)}"`
75757676+ // JSON.stringify cannot serialize Error instances
7777+ if (functionName === 'onUnhandledError')
7878+ message += ` with "${args[0]?.message || args[0]}"`
7979+7680 throw new Error(message)
7781 },
7882 ...options,
+1-8
packages/vitest/src/runtime/worker.ts
···33import { ModuleCacheMap } from 'vite-node/client'
44import type { ContextRPC } from '../types/rpc'
55import { loadEnvironment } from '../integrations/env/loader'
66-import type { WorkerGlobalState } from '../types/worker'
76import { isChildProcess, setProcessTitle } from '../utils/base'
87import { setupInspect } from './inspector'
98import { createRuntimeRpc, rpcDone } from './rpc'
···20192120 process.env.VITEST_WORKER_ID = String(ctx.workerId)
2221 process.env.VITEST_POOL_ID = String(poolId)
2323-2424- let state: WorkerGlobalState | null = null
25222623 try {
2724 // worker is a filepath or URL to a file that exposes a default export with "getRpcOptions" and "runTests" methods
···4643 if (ctx.environment.transformMode)
4744 environment.transformMode = ctx.environment.transformMode
48454949- state = {
4646+ const state = {
5047 ctx,
5148 // here we create a new one, workers can reassign this if they need to keep it non-isolated
5249 moduleCache: new ModuleCacheMap(),
···7067 finally {
7168 await rpcDone().catch(() => {})
7269 inspectorCleanup()
7373- if (state) {
7474- state.environment = null as any
7575- state = null
7676- }
7770 }
7871}