@@ -242,6 +242,8 @@ interface ParseRequestHeadersOptions {
242
242
}
243
243
244
244
const flightDataPathHeadKey = 'h'
245
+ const getFlightViewportKey = ( requestId : string ) => requestId + 'v'
246
+ const getFlightMetadataKey = ( requestId : string ) => requestId + 'm'
245
247
246
248
interface ParsedRequestHeaders {
247
249
/**
@@ -516,9 +518,9 @@ async function generateDynamicRSCPayload(
516
518
isPossibleServerAction = { ctx . isPossibleServerAction }
517
519
/>
518
520
{ /* Adding requestId as react key to make metadata remount for each render */ }
519
- < ViewportTree key = { requestId } />
521
+ < ViewportTree key = { getFlightViewportKey ( requestId ) } />
520
522
{ /* Not add requestId as react key to ensure segment prefetch could result consistently if nothing changed */ }
521
- < MetadataTree />
523
+ < MetadataTree key = { getFlightMetadataKey ( requestId ) } />
522
524
</ React . Fragment >
523
525
) ,
524
526
injectedCSS : new Set ( ) ,
@@ -852,7 +854,7 @@ async function getRSCPayload(
852
854
statusCode = { ctx . res . statusCode }
853
855
isPossibleServerAction = { ctx . isPossibleServerAction }
854
856
/>
855
- < ViewportTree key = { ctx . requestId } />
857
+ < ViewportTree key = { getFlightViewportKey ( ctx . requestId ) } />
856
858
{ /* Not add requestId as react key to ensure segment prefetch could result consistently if nothing changed */ }
857
859
< MetadataTree />
858
860
</ React . Fragment >
@@ -941,12 +943,8 @@ async function getErrorRSCPayload(
941
943
serveStreamingMetadata : serveStreamingMetadata ,
942
944
} )
943
945
944
- const metadata = (
945
- < React . Fragment key = { flightDataPathHeadKey } >
946
- { /* Adding requestId as react key to make metadata remount for each render */ }
947
- < MetadataTree key = { requestId } />
948
- </ React . Fragment >
949
- )
946
+ // {/* Adding requestId as react key to make metadata remount for each render */}
947
+ const metadata = < MetadataTree key = { getFlightMetadataKey ( requestId ) } />
950
948
951
949
const initialHead = (
952
950
< React . Fragment key = { flightDataPathHeadKey } >
@@ -956,7 +954,7 @@ async function getErrorRSCPayload(
956
954
isPossibleServerAction = { ctx . isPossibleServerAction }
957
955
/>
958
956
{ /* Adding requestId as react key to make metadata remount for each render */ }
959
- < ViewportTree key = { requestId } />
957
+ < ViewportTree key = { getFlightViewportKey ( requestId ) } />
960
958
{ process . env . NODE_ENV === 'development' && (
961
959
< meta name = "next-error" content = "not-found" />
962
960
) }
0 commit comments