Repository navigation
fix(app-router): fulfill pending segment data when reused during pushState or traversal - #100502
Draft
wasim-builds wants to merge 1 commit into
Draft
wasim-builds wants to merge 1 commit into
wasim-builds wants to merge 1 commit into
Conversation
…State or traversal When a navigation or pushState history traversal occurs while an earlier navigation/refresh is still streaming or superseded, the shared route segments may reuse the existing cache node. Previously, reusing the segment hardcoded `needsDynamicRequest = false` without checking if the reused node's `rsc` was still pending. This caused `spawnDynamicRequests` to skip fetching the missing dynamic data, leaving React's transition lanes suspended and `useTransition.isPending` stuck on `true` forever. Now, `needsDynamicRequest` is set to `!oldRscDidResolve` when reusing cache nodes, ensuring any still-pending deferred RSC promise is fulfilled by a dynamic request. Fixes vercel#100489.
This branch has not been deployed
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.
Closes #100489
What?
When a navigation or
history.pushStatetraversal occurs while an earlier action's refresh or navigation is still streaming in (or was superseded), the shared route segments may reuse the existing cache node.Previously,
updateRenderTreeOnNavigationand segment cache reuse paths hardcodedneedsDynamicRequest = falsewithout checking if the reused cache node'srscwas still a pendingDeferredRsc. As a result,spawnDynamicRequestsskipped requesting dynamic data for the unfulfilled segments, leaving React's transition lanes suspended (pendingLanes = suspendedLanes = entangledLanes = 0b111000000000) anduseTransition.isPendingstuck ontrueforever until a full page reload.Why?
finishNavigationTaskcaseNavigationTaskExitStatus.Canceledintentionally leaves pending cache nodes untouched under the contract:However, because reusing the existing segment unconditionally set
needsDynamicRequest = false, the newer request was never spawned, and nothing fulfilled the pending deferred RSC promises.How?
updateRenderTreeOnNavigation, checkoldRscDidResolve = !isDeferredRsc(oldRsc) || oldRsc.status !== 'pending'when reusingoldRenderTree.data. IfoldRschas not resolved, setneedsDynamicRequest = !oldRscDidResolveso thatcreateDynamicRequestTreeandspawnDynamicRequestsschedule a request to fulfill the missing segment data.needsDynamicRequest = !oldRscDidResolvecheck to BFCache and param-unchanged segment reuse paths inrender-tree.ts.test/e2e/app-dir/concurrent-navigations/server-patch-history.test.tsreproducing the discarded Server Action + in-flight streamed refresh + consecutivepushStatecalls.