Skip to content

fix: suppress flaky Vitest worker RPC shutdown crash in agents-manage-ui#2046

Merged
nick-inkeep merged 2 commits intomainfrom
fix/vitest-worker-crash-resilience
Feb 16, 2026
Merged

fix: suppress flaky Vitest worker RPC shutdown crash in agents-manage-ui#2046
nick-inkeep merged 2 commits intomainfrom
fix/vitest-worker-crash-resilience

Conversation

@nick-inkeep
Copy link
Collaborator

Summary

  • Add targeted onUnhandledError filter in agents-manage-ui/vitest.config.ts to suppress the known Vitest worker RPC shutdown race condition ("Closing rpc while fetch was pending")

Problem

The agents-manage-ui test suite intermittently fails in CI with:

Error: [vitest-worker]: Closing rpc while "fetch" was pending

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 onUnhandledError callback to selectively suppress errors matching "Closing rpc while". This:

  • Only filters the specific known error — all other unhandled errors propagate normally
  • Does not use dangerouslyIgnoreUnhandledErrors (which would hide all errors)
  • Introduces zero functional changes — no test behavior, assertions, or coverage is affected
  • All 201 existing tests continue to pass identically

Test plan

  • All 20 non-browser test files pass (201 tests)
  • Lint/format clean
  • Pre-commit hooks pass
  • No functional changes — same test count and behavior before/after

🤖 Generated with Claude Code

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>
@changeset-bot
Copy link

changeset-bot bot commented Feb 16, 2026

⚠️ No Changeset found

Latest commit: 6007972

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link

vercel bot commented Feb 16, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agents-api Ready Ready Preview, Comment Feb 16, 2026 11:25pm
agents-docs Ready Ready Preview, Comment Feb 16, 2026 11:25pm
agents-manage-ui Ready Ready Preview, Comment Feb 16, 2026 11:25pm

Request Review

Copy link
Contributor

@claude claude bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. Uses the official API correctlyonUnhandledError is Vitest's designated callback for handling unhandled errors
  2. Is appropriately targeted — Only suppresses errors containing "Closing rpc while", allowing all other unhandled errors to propagate normally
  3. Includes good documentation — The comment block explains the "what", "why", and links to the upstream Vitest issue (#9458)
  4. Avoids the dangerous alternative — Does not use dangerouslyIgnoreUnhandledErrors which would hide all errors
  5. 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

@github-actions github-actions bot deleted a comment from claude bot Feb 16, 2026
Copy link
Contributor

@claude claude bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. No conflicts — The original vitest.config.ts changes are unchanged and unaffected by the merged code
  2. Consistent patterns — The CI cache key patterns in ci.yml and cypress.yml are identical and well-formed
  3. Valid configuration — The turbopackFileSystemCacheForBuild: true experimental flag in next.config.ts is 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.

@github-actions github-actions bot deleted a comment from claude bot Feb 16, 2026
@nick-inkeep nick-inkeep merged commit ad63f54 into main Feb 16, 2026
11 checks passed
@nick-inkeep nick-inkeep deleted the fix/vitest-worker-crash-resilience branch February 16, 2026 23:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant