@@ -1760,6 +1760,7 @@ async function renderToHTMLOrFlightImpl(
1760
1760
renderToStream
1761
1761
)
1762
1762
1763
+ let didExecuteServerAction = false
1763
1764
let formState : null | any = null
1764
1765
if ( isPossibleActionRequest ) {
1765
1766
// For action requests, we don't want to use the resume data cache.
@@ -1794,7 +1795,7 @@ async function renderToHTMLOrFlightImpl(
1794
1795
postponedState ,
1795
1796
metadata ,
1796
1797
devValidatingFallbackParams ,
1797
- createRequestStore
1798
+ undefined // Prevent restartable-render behavior in dev + Cache Components mode
1798
1799
)
1799
1800
1800
1801
return new RenderResult ( stream , {
@@ -1811,6 +1812,7 @@ async function renderToHTMLOrFlightImpl(
1811
1812
}
1812
1813
}
1813
1814
1815
+ didExecuteServerAction = true
1814
1816
// Restore the resume data cache
1815
1817
requestStore . renderResumeDataCache = renderResumeDataCache
1816
1818
}
@@ -1832,7 +1834,12 @@ async function renderToHTMLOrFlightImpl(
1832
1834
postponedState ,
1833
1835
metadata ,
1834
1836
devValidatingFallbackParams ,
1835
- createRequestStore
1837
+ // If we're rendering HTML after an action, we don't want restartable-render behavior
1838
+ // because the result should be dynamic, like it is in prod.
1839
+ // Also, the request store might have been mutated by the action (e.g. enabling draftMode)
1840
+ // and we currently we don't copy changes over when creating a new store,
1841
+ // so the restarted render wouldn't be correct.
1842
+ didExecuteServerAction ? undefined : createRequestStore
1836
1843
)
1837
1844
1838
1845
// Invalid dynamic usages should only error the request in development.
@@ -2032,7 +2039,7 @@ async function renderToStream(
2032
2039
postponedState : PostponedState | null ,
2033
2040
metadata : AppPageRenderResultMetadata ,
2034
2041
devValidatingFallbackParams : OpaqueFallbackRouteParams | null ,
2035
- createRequestStore : ( ) => RequestStore
2042
+ createRequestStore : ( ( ) => RequestStore ) | undefined
2036
2043
) : Promise < ReadableStream < Uint8Array > > {
2037
2044
const { assetPrefix, htmlRequestId, nonce, pagePath, renderOpts, requestId } =
2038
2045
ctx
@@ -2152,7 +2159,10 @@ async function renderToStream(
2152
2159
// Edge routes never prerender so we don't have a Prerender environment for anything in edge runtime
2153
2160
process . env . NEXT_RUNTIME !== 'edge' &&
2154
2161
// We only have a Prerender environment for projects opted into cacheComponents
2155
- experimental . cacheComponents
2162
+ experimental . cacheComponents &&
2163
+ // We only do this flow if we can safely recreate the store from scratch
2164
+ // (which is not the case for renders after an action)
2165
+ createRequestStore
2156
2166
) {
2157
2167
type RSCPayloadWithValidation = InitialRSCPayload & {
2158
2168
/** Only available during cacheComponents development builds. Used for logging errors. */
0 commit comments