[vitest-pool-workers] Add regression tests for onUnhandledError callback - #13076
Conversation
|
|
I've now thoroughly reviewed the PR. Let me assess the changes:
This is a clean, well-structured regression test that follows the existing patterns in the test suite. No logic bugs, no security issues, no backward compatibility concerns. LGTM |
create-cloudflare
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-shared
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-pool-workers
@cloudflare/workers-editor-shared
wrangler
commit: |
|
Codeowners approval required for this PR:
Show detailed file reviewers |
Fixes #11532.
The
onUnhandledErrorcallback was not being invoked with@cloudflare/vitest-pool-workerson versions prior to 0.13.0. This was fixed by thenodejs_process_v2compatibility flag enforcement added in the Vitest 4 support rewrite (#11632) — workerd's nativeprocess.on('unhandledRejection')support is what Vitest's internallistenForErrors()relies on.This PR adds regression tests to ensure the callback continues to work:
Promise.reject()causes the test run to exit non-zeroonUnhandledErrorcan suppress specific errors — verifies that returningfalsefrom the callback prevents the error from failing the runNote: errors from workers are serialised plain objects (via Vitest's
serializeValue), notErrorinstances — this is consistent with standard Vitest pools (threads/forks). The test uses.messageproperty access rather thaninstanceof Error, matching the Vitest docs example.