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