@@ -1701,7 +1701,9 @@ async function renderToHTMLOrFlightImpl(
1701
1701
const rootParams = getRootParams ( loaderTree , ctx . getDynamicParamFromSegment )
1702
1702
const devValidatingFallbackParams =
1703
1703
getRequestMeta ( req , 'devValidatingFallbackParams' ) || null
1704
- const requestStore = createRequestStoreForRender (
1704
+
1705
+ const createRequestStore = createRequestStoreForRender . bind (
1706
+ null ,
1705
1707
req ,
1706
1708
res ,
1707
1709
url ,
@@ -1714,6 +1716,7 @@ async function renderToHTMLOrFlightImpl(
1714
1716
renderResumeDataCache ,
1715
1717
devValidatingFallbackParams
1716
1718
)
1719
+ const requestStore = createRequestStore ( )
1717
1720
1718
1721
if (
1719
1722
process . env . NODE_ENV === 'development' &&
@@ -1725,6 +1728,9 @@ async function renderToHTMLOrFlightImpl(
1725
1728
) {
1726
1729
const setIsrStatus = renderOpts . setIsrStatus
1727
1730
req . originalRequest . on ( 'end' , ( ) => {
1731
+ // Note: if we're in Cache Components mode, and we restart the render due to a cache miss,
1732
+ // we'll create a new request store, and the ISR status will not be picked up here.
1733
+ // This is fine, because the indicator isn't useful in CC mode anyway.
1728
1734
if ( ! requestStore . usedDynamic && ! workStore . forceDynamic ) {
1729
1735
// only node can be ISR so we only need to update the status here
1730
1736
const { pathname } = new URL ( req . url || '/' , 'http://n' )
@@ -1785,7 +1791,8 @@ async function renderToHTMLOrFlightImpl(
1785
1791
formState ,
1786
1792
postponedState ,
1787
1793
metadata ,
1788
- devValidatingFallbackParams
1794
+ devValidatingFallbackParams ,
1795
+ createRequestStore
1789
1796
)
1790
1797
1791
1798
return new RenderResult ( stream , {
@@ -1812,6 +1819,8 @@ async function renderToHTMLOrFlightImpl(
1812
1819
}
1813
1820
1814
1821
const stream = await renderToStreamWithTracing (
1822
+ // NOTE: in Cache Components (dev), if the render is restarted, it will use a different requestStore
1823
+ // than the one that we're passing in here.
1815
1824
requestStore ,
1816
1825
req ,
1817
1826
res ,
@@ -1820,7 +1829,8 @@ async function renderToHTMLOrFlightImpl(
1820
1829
formState ,
1821
1830
postponedState ,
1822
1831
metadata ,
1823
- devValidatingFallbackParams
1832
+ devValidatingFallbackParams ,
1833
+ createRequestStore
1824
1834
)
1825
1835
1826
1836
// Invalid dynamic usages should only error the request in development.
@@ -2004,7 +2014,8 @@ async function renderToStream(
2004
2014
formState : any ,
2005
2015
postponedState : PostponedState | null ,
2006
2016
metadata : AppPageRenderResultMetadata ,
2007
- devValidatingFallbackParams : OpaqueFallbackRouteParams | null
2017
+ devValidatingFallbackParams : OpaqueFallbackRouteParams | null ,
2018
+ createRequestStore : ( ) => RequestStore
2008
2019
) : Promise < ReadableStream < Uint8Array > > {
2009
2020
const { assetPrefix, htmlRequestId, nonce, pagePath, renderOpts, requestId } =
2010
2021
ctx
@@ -2265,8 +2276,7 @@ async function renderToStream(
2265
2276
2266
2277
// The initial render acted as a prospective render to warm the caches.
2267
2278
// Now, we need to do another render.
2268
-
2269
- // TODO(restart-on-cache-miss): we should use a separate request store for this instead
2279
+ requestStore = createRequestStore ( )
2270
2280
2271
2281
// We've filled the caches, so now we can render as usual.
2272
2282
requestStore . prerenderResumeDataCache = null
@@ -2275,10 +2285,6 @@ async function renderToStream(
2275
2285
)
2276
2286
requestStore . cacheSignal = null
2277
2287
2278
- // Reset mutable fields.
2279
- requestStore . prerenderPhase = undefined
2280
- requestStore . usedDynamic = undefined
2281
-
2282
2288
// The initial render already wrote to its debug channel. We're not using it,
2283
2289
// so we need to create a new one.
2284
2290
const finalRenderDebugChannel =
0 commit comments