@@ -1706,7 +1706,9 @@ async function renderToHTMLOrFlightImpl(
1706
1706
const rootParams = getRootParams ( loaderTree , ctx . getDynamicParamFromSegment )
1707
1707
const devValidatingFallbackParams =
1708
1708
getRequestMeta ( req , 'devValidatingFallbackParams' ) || null
1709
- const requestStore = createRequestStoreForRender (
1709
+
1710
+ const createRequestStore = createRequestStoreForRender . bind (
1711
+ null ,
1710
1712
req ,
1711
1713
res ,
1712
1714
url ,
@@ -1719,6 +1721,7 @@ async function renderToHTMLOrFlightImpl(
1719
1721
renderResumeDataCache ,
1720
1722
devValidatingFallbackParams
1721
1723
)
1724
+ const requestStore = createRequestStore ( )
1722
1725
1723
1726
if (
1724
1727
process . env . NODE_ENV === 'development' &&
@@ -1791,7 +1794,8 @@ async function renderToHTMLOrFlightImpl(
1791
1794
formState ,
1792
1795
postponedState ,
1793
1796
metadata ,
1794
- devValidatingFallbackParams
1797
+ devValidatingFallbackParams ,
1798
+ createRequestStore
1795
1799
)
1796
1800
1797
1801
return new RenderResult ( stream , {
@@ -1818,6 +1822,8 @@ async function renderToHTMLOrFlightImpl(
1818
1822
}
1819
1823
1820
1824
const stream = await renderToStreamWithTracing (
1825
+ // NOTE: in Cache Components (dev), if the render is restarted, it will use a different requestStore
1826
+ // than the one that we're passing in here.
1821
1827
requestStore ,
1822
1828
req ,
1823
1829
res ,
@@ -1826,7 +1832,8 @@ async function renderToHTMLOrFlightImpl(
1826
1832
formState ,
1827
1833
postponedState ,
1828
1834
metadata ,
1829
- devValidatingFallbackParams
1835
+ devValidatingFallbackParams ,
1836
+ createRequestStore
1830
1837
)
1831
1838
1832
1839
// Invalid dynamic usages should only error the request in development.
@@ -2025,7 +2032,8 @@ async function renderToStream(
2025
2032
formState : any ,
2026
2033
postponedState : PostponedState | null ,
2027
2034
metadata : AppPageRenderResultMetadata ,
2028
- devValidatingFallbackParams : OpaqueFallbackRouteParams | null
2035
+ devValidatingFallbackParams : OpaqueFallbackRouteParams | null ,
2036
+ createRequestStore : ( ) => RequestStore
2029
2037
) : Promise < ReadableStream < Uint8Array > > {
2030
2038
const { assetPrefix, htmlRequestId, nonce, pagePath, renderOpts, requestId } =
2031
2039
ctx
@@ -2286,8 +2294,7 @@ async function renderToStream(
2286
2294
2287
2295
// The initial render acted as a prospective render to warm the caches.
2288
2296
// Now, we need to do another render.
2289
-
2290
- // TODO(restart-on-cache-miss): we should use a separate request store for this instead
2297
+ requestStore = createRequestStore ( )
2291
2298
2292
2299
// We've filled the caches, so now we can render as usual.
2293
2300
requestStore . prerenderResumeDataCache = null
@@ -2296,10 +2303,6 @@ async function renderToStream(
2296
2303
)
2297
2304
requestStore . cacheSignal = null
2298
2305
2299
- // Reset mutable fields.
2300
- requestStore . prerenderPhase = undefined
2301
- requestStore . usedDynamic = undefined
2302
-
2303
2306
// The initial render already wrote to its debug channel. We're not using it,
2304
2307
// so we need to create a new one.
2305
2308
const finalRenderDebugChannel =
0 commit comments