fix(router-core): close instead of error stream on lifetime watchdog expiry - #7909
Open
Brumor wants to merge 1 commit into
Open
fix(router-core): close instead of error stream on lifetime watchdog expiry#7909Brumor wants to merge 1 commit into
Brumor wants to merge 1 commit into
Conversation
Contributor
📝 WalkthroughWalkthroughThe SSR transform lifetime watchdog now closes timed-out streams instead of erroring them. Tests cover both fast and main paths with and without active readers, and a patch changeset documents the release. ChangesSSR stream timeout handling
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Brumor
marked this pull request as ready for review
July 27, 2026 15:35
Contributor
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/router-core/tests/transformStreamWithRouter.test.ts`:
- Around line 679-680: Remove the any casts from the router and stream arguments
in the watchdog test around the transform invocation. Update the test fixtures
and their declarations to satisfy the required router and upstream stream
contracts directly, preserving the existing behavior while allowing TypeScript
strict checking to catch API incompatibilities.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 730e3f39-0ccd-47fd-8e08-525ae3c6c986
📒 Files selected for processing (3)
.changeset/calm-streams-close.mdpackages/router-core/src/ssr/transformStreamWithRouter.tspackages/router-core/tests/transformStreamWithRouter.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #7748
#7748 has a nice minimal repro and isolates this to two layers: the Nitro V2 dev adapter misses a client abort, then router-core turns the abandoned stream into an unhandled error when the lifetime watchdog fires two minutes later. This PR fixes the router-core half, so a missed cancellation cannot take down the server runtime.
Basically: the watchdog is a leak-prevention fallback. By the time it fires, there is no useful consumer left to receive the error.
This changes both router-core stream paths to close cleanly when the lifetime watchdog fires. The existing warning and cleanup reason stay in place, so the upstream app render is still cancelled and the SSR resources are released. Real render and serialization failures still error the stream.
Added coverage for the fast and main paths, both with and without an active reader.
Tests:
Summary by CodeRabbit
Bug Fixes
Tests