Refactor: scope requestStore to dynamic renders only (#72312)#5
Refactor: scope requestStore to dynamic renders only (#72312)#5MitchLewis930 wants to merge 1 commit intopr_035_beforefrom
Conversation
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
Greptile OverviewGreptile SummaryThis PR refactors the
This refactoring improves performance by avoiding unnecessary Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Client
participant renderToHTMLOrFlight
participant workAsyncStorage
participant renderToHTMLOrFlightImpl
participant Dynamic Render Branch
participant requestStore
participant workUnitAsyncStorage
participant generateDynamicFlightRenderResult
participant actionHandler
Client->>renderToHTMLOrFlight: Request
renderToHTMLOrFlight->>workAsyncStorage: run(workStore, renderToHTMLOrFlightImpl, ...)
workAsyncStorage->>renderToHTMLOrFlightImpl: Execute with workStore context
alt Static Render
renderToHTMLOrFlightImpl->>renderToHTMLOrFlightImpl: Return static result
else Dynamic Render
renderToHTMLOrFlightImpl->>Dynamic Render Branch: Enter dynamic path
Dynamic Render Branch->>requestStore: createRequestStoreForRender()
Note over Dynamic Render Branch,requestStore: requestStore now created only for dynamic renders
alt RSC Request
Dynamic Render Branch->>workUnitAsyncStorage: run(requestStore, generateDynamicFlightRenderResult, ...)
workUnitAsyncStorage->>generateDynamicFlightRenderResult: Execute with requestStore context
generateDynamicFlightRenderResult->>workUnitAsyncStorage: run(requestStore, generateDynamicRSCPayload, ...)
generateDynamicFlightRenderResult->>workUnitAsyncStorage: run(requestStore, renderToReadableStream, ...)
else Action Request
Dynamic Render Branch->>actionHandler: handleAction()
actionHandler->>workUnitAsyncStorage: run(requestStore, actionHandler.apply, ...)
workUnitAsyncStorage->>actionHandler: Execute action with requestStore context
actionHandler->>workUnitAsyncStorage: finalizeAndGenerateFlight(req, ctx, requestStore, ...)
end
end
renderToHTMLOrFlightImpl-->>Client: Response
|
PR_035