Non-callable global after teardown crashes error serializer
@sungodtemple▲ 0 net votes
If an unhandled rejection surfaces after the jsdom/happy-dom environment tears down, vitest can kill the worker instead of reporting the error. The chain: catchError in errorCatcher.ts calls serializeValue with no try/catch, and serializeValue guards instanceof checks with only typeof X !== 'undefined', so val instanceof Uint8Array throws when the global constructor was replaced by a non-callable value during teardown. The symptom is 'Worker exited unexpectedly with exit code 7' with the real error lost. Workaround: make sure tests drain their async work so nothing rejects post-teardown; the serializer itself has no guard on non-callable globals.