fix(app-router): cancel live RSC redirect bodies before refetch#2559
Open
NathanDrake2406 wants to merge 1 commit into
Open
fix(app-router): cancel live RSC redirect bodies before refetch#2559NathanDrake2406 wants to merge 1 commit into
NathanDrake2406 wants to merge 1 commit into
Conversation
Live response-URL RSC redirect hops fetch the redirected target in a new navigation-loop iteration. The abandoned response body remained unread because the planner marked those hops as non-discarding, so Workers-compatible fetch implementations could keep the underlying stream open. Mark live response-URL follow decisions as body-discarding while leaving cached-source decisions unchanged because they have no live stream to release. The browser executor already cancels discarded bodies before continuing the redirect loop. The planner regression now asserts live response-URL redirects require body discard and preserves cached redirect reuse.
commit: |
Contributor
Performance benchmarksCompared 0 improved · 0 regressed · 6 within ±1.5%
View detailed results and traces 🟢 improvement · 🔴 regression · ⚫ change below 1.5% · paired base/head |
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.
Overview
followRedirectdecisions now setdiscardBody: truefor live fetch results. Cached-source redirect decisions stay non-discarding because they have no live stream to release.navigation-plannerowns the discard decision.app-browser-entryalready owns the effect by cancelling bodies for discarded fetch results before continuing.navigation-planner.tsupdates the planner contract.navigation-planner-rsc-fetch-result.test.tscovers live and cached redirect decisions.Why
RSC redirect replay is a resource-ownership boundary: once the client decides to ignore a live response and fetch the redirected target, it no longer has a consumer for the original body. The planner already tells the browser executor when streamed-header redirect bodies are discarded; live response-URL follow hops need the same signal so the executor can release the unread body before the next fetch.
followRedirectdecisions asdiscardBody: true.app-browser-entrydiscard path instead of adding a second effect path.discardBody: falsefor cached response-URL redirect decisions.What changed
discardBody: false; executor continued the redirect loop without cancelling the old body.discardBody: true; existing executor code cancels the old body before refetching the target.discardBody: false.discardBody: true.Fixes #1987.
Validation
vp test run tests/navigation-planner-rsc-fetch-result.test.ts -t "follows live response-URL redirects and requires body discard"discardBody: false.vp test run tests/navigation-planner-rsc-fetch-result.test.tsvp test run tests/app-browser-entry.test.ts -t "app browser RSC redirect lifecycle"vp test run tests/navigation-planner-rsc-fetch-result.test.ts tests/app-browser-entry.test.tsvp checkgit diff --checkRisk / compatibility
Non-goals
References