fix: suppress flaky Vitest worker RPC shutdown crash in agents-manage-ui#2046
fix: suppress flaky Vitest worker RPC shutdown crash in agents-manage-ui#2046nick-inkeep merged 2 commits intomainfrom
Conversation
Add targeted onUnhandledError filter for the known "Closing rpc while fetch was pending" error that occurs when Vitest workers shut down while Next.js background dynamic imports are still resolving. This is a documented Vitest limitation (vitest-dev/vitest#9458) — the error is an unhandled rejection during worker teardown, not a test failure. The filter only suppresses errors matching "Closing rpc while" and lets all other unhandled errors propagate normally. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
PR Review Summary
(0) Total Issues | Risk: Low
This PR adds a targeted error suppression for a known Vitest worker RPC shutdown race condition. The implementation is clean, well-documented, and follows best practices.
Assessment
✅ No issues identified. The change:
- Uses the official API correctly —
onUnhandledErroris Vitest's designated callback for handling unhandled errors - Is appropriately targeted — Only suppresses errors containing
"Closing rpc while", allowing all other unhandled errors to propagate normally - Includes good documentation — The comment block explains the "what", "why", and links to the upstream Vitest issue (#9458)
- Avoids the dangerous alternative — Does not use
dangerouslyIgnoreUnhandledErrorswhich would hide all errors - Has zero functional impact — No test behavior, assertions, or coverage changes
The return false convention to suppress the error is correct per Vitest's API — returning a falsy value prevents the error from failing the test run.
✅ APPROVE
Summary: Clean, well-scoped fix for a known Vitest limitation with Next.js. The narrowly-targeted error filter is the right approach — ship it! 🚀
Reviewers (2)
| Reviewer | Returned | Main Findings | Consider | While You're Here | Inline Comments | Pending Recs | Discarded |
|---|---|---|---|---|---|---|---|
pr-review-devops |
0 | 0 | 0 | 0 | 0 | 0 | 0 |
pr-review-standards |
0 | 0 | 0 | 0 | 0 | 0 | 0 |
| Total | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
There was a problem hiding this comment.
PR Review Summary
(0) Total Issues | Risk: Low
This is a re-review triggered by new commits. The delta since the last review consists of a merge commit bringing in PR #2045 (Turbopack filesystem cache improvements) from main.
Delta Assessment
✅ No issues identified in the delta. The merge is clean with:
- No conflicts — The original
vitest.config.tschanges are unchanged and unaffected by the merged code - Consistent patterns — The CI cache key patterns in
ci.ymlandcypress.ymlare identical and well-formed - Valid configuration — The
turbopackFileSystemCacheForBuild: trueexperimental flag innext.config.tsis correctly placed
Original Changes (Unchanged)
The original PR changes adding onUnhandledError in vitest.config.ts remain as previously reviewed and approved:
- Uses Vitest's official API correctly
- Appropriately targets only the specific
"Closing rpc while"error pattern - Includes proper documentation with upstream issue reference
✅ APPROVE
Summary: Clean merge of main into the feature branch. The original vitest fix remains sound, and the merged caching improvements introduce no conflicts or issues. Ready to ship! 🚀
Reviewers (2)
| Reviewer | Returned | Main Findings | Consider | While You're Here | Inline Comments | Pending Recs | Discarded |
|---|---|---|---|---|---|---|---|
pr-review-devops |
0 | 0 | 0 | 0 | 0 | 0 | 0 |
pr-review-standards |
0 | 0 | 0 | 0 | 0 | 0 | 0 |
| Total | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Note: Delta-scoped re-review — reviewers focused only on changes since last automated review.
Summary
onUnhandledErrorfilter inagents-manage-ui/vitest.config.tsto suppress the known Vitest worker RPC shutdown race condition ("Closing rpc while fetch was pending")Problem
The
agents-manage-uitest suite intermittently fails in CI with:All individual tests pass — the failure is an Unhandled Rejection during worker teardown, not a test assertion failure. This is a documented Vitest limitation caused by Next.js background dynamic imports that outlive test execution.
Solution
Use Vitest's official
onUnhandledErrorcallback to selectively suppress errors matching"Closing rpc while". This:dangerouslyIgnoreUnhandledErrors(which would hide all errors)Test plan
🤖 Generated with Claude Code