Skip to content

Comments

Refactor: scope requestStore to dynamic renders only (#72312)#5

Open
MitchLewis930 wants to merge 1 commit intopr_035_beforefrom
pr_035_after
Open

Refactor: scope requestStore to dynamic renders only (#72312)#5
MitchLewis930 wants to merge 1 commit intopr_035_beforefrom
pr_035_after

Conversation

@MitchLewis930
Copy link

@MitchLewis930 MitchLewis930 commented Jan 30, 2026

PR_035


Note

Medium Risk
Touches core App Router render/action plumbing and async storage scoping; regressions could affect request context (cookies, HMR refresh, ISR status) during dynamic renders and Server Actions.

Overview
Refactors app rendering so requestStore is created and scoped only for dynamic renders, instead of being built up-front for all requests. This changes the renderToHTMLOrFlight call stack to pass args through workAsyncStorage.run(...) directly and creates the requestStore inside the dynamic branch (also moving the dev setAppIsrStatus update there).

Updates server action + Flight generation to consistently run under workUnitAsyncStorage with the correct requestStore (including wrapping action execution, generateDynamicRSCPayload, and renderToReadableStream), and threads requestStore explicitly through generateFlight/finalizeAndGenerateFlight.

Tweaks createRequestStoreForRender’s parameter ordering to accommodate the new call sites (adding serverComponentsHmrCache/resume cache ordering).

Written by Cursor Bugbot for commit 071a059. This will update automatically on new commits. Configure here.

This completes the refactor to eliminate a requestStore scoped around
prerenders. Now we only scope requestStore around dynamic renders. If
you are prerendering then the workUnitAsyncStorage will only have a
prerneder store or undefined. While it is possible to shadow stores
because you can enter a cache scope from a render or prerender it
generally should never be the case that you enter a prerender from a
request or enter a request from a prerender. These are effectively top
level scopes.

This should not change any program behavior

stacked on vercel#72212
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.

2 participants