@@ -1104,7 +1104,8 @@ if (__DEV__) {
11041104 bundlerConfig ,
11051105 onError ,
11061106 identifierPrefix ,
1107- onPostpone
1107+ onPostpone ,
1108+ environmentName
11081109 ) {
11091110 if (
11101111 ReactCurrentCache . current !== null &&
@@ -1149,6 +1150,12 @@ if (__DEV__) {
11491150 onPostpone :
11501151 onPostpone === undefined ? defaultPostponeHandler : onPostpone
11511152 } ;
1153+
1154+ {
1155+ request . environmentName =
1156+ environmentName === undefined ? "server" : environmentName ;
1157+ }
1158+
11521159 var rootTask = createTask ( request , model , null , false , abortSet ) ;
11531160 pingedTasks . push ( rootTask ) ;
11541161 return request ;
@@ -1169,6 +1176,15 @@ if (__DEV__) {
11691176 request . abortableTasks
11701177 ) ;
11711178
1179+ {
1180+ // If this came from Flight, forward any debug info into this new row.
1181+ var debugInfo = thenable . _debugInfo ;
1182+
1183+ if ( debugInfo ) {
1184+ forwardDebugInfo ( request , newTask . id , debugInfo ) ;
1185+ }
1186+ }
1187+
11721188 switch ( thenable . status ) {
11731189 case "fulfilled" : {
11741190 // We have the resolved value, we can go ahead and schedule it for serialization.
@@ -1308,6 +1324,12 @@ if (__DEV__) {
13081324 _payload : thenable ,
13091325 _init : readThenable
13101326 } ;
1327+
1328+ {
1329+ // If this came from React, transfer the debug info.
1330+ lazyType . _debugInfo = thenable . _debugInfo || [ ] ;
1331+ }
1332+
13111333 return lazyType ;
13121334 }
13131335
@@ -1329,7 +1351,8 @@ if (__DEV__) {
13291351 var componentName = Component . displayName || Component . name || "" ;
13301352 request . pendingChunks ++ ;
13311353 emitDebugChunk ( request , debugID , {
1332- name : componentName
1354+ name : componentName ,
1355+ env : request . environmentName
13331356 } ) ;
13341357 }
13351358 }
@@ -1378,6 +1401,24 @@ if (__DEV__) {
13781401 }
13791402
13801403 function renderFragment ( request , task , children ) {
1404+ {
1405+ var debugInfo = children . _debugInfo ;
1406+
1407+ if ( debugInfo ) {
1408+ // If this came from Flight, forward any debug info into this new row.
1409+ if ( debugID === null ) {
1410+ // We don't have a chunk to assign debug info. We need to outline this
1411+ // component to assign it an ID.
1412+ return outlineTask ( request , task ) ;
1413+ } else {
1414+ // Forward any debug info we have the first time we see it.
1415+ // We do this after init so that we have received all the debug info
1416+ // from the server by the time we emit it.
1417+ forwardDebugInfo ( request , debugID , debugInfo ) ;
1418+ }
1419+ }
1420+ }
1421+
13811422 if ( task . keyPath !== null ) {
13821423 // We have a Server Component that specifies a key but we're now splitting
13831424 // the tree using a fragment.
@@ -1969,7 +2010,23 @@ if (__DEV__) {
19692010 _writtenObjects . set ( value , - 1 ) ;
19702011 }
19712012
1972- var element = value ; // Attempt to render the Server Component.
2013+ var element = value ;
2014+
2015+ {
2016+ var debugInfo = value . _debugInfo ;
2017+
2018+ if ( debugInfo ) {
2019+ // If this came from Flight, forward any debug info into this new row.
2020+ if ( debugID === null ) {
2021+ // We don't have a chunk to assign debug info. We need to outline this
2022+ // component to assign it an ID.
2023+ return outlineTask ( request , task ) ;
2024+ } else {
2025+ // Forward any debug info we have the first time we see it.
2026+ forwardDebugInfo ( request , debugID , debugInfo ) ;
2027+ }
2028+ }
2029+ } // Attempt to render the Server Component.
19732030
19742031 return renderElement (
19752032 request ,
@@ -1982,9 +2039,32 @@ if (__DEV__) {
19822039 }
19832040
19842041 case REACT_LAZY_TYPE : {
1985- var payload = value . _payload ;
1986- var init = value . _init ;
2042+ // Reset the task's thenable state before continuing. If there was one, it was
2043+ // from suspending the lazy before.
2044+ task . thenableState = null ;
2045+ var lazy = value ;
2046+ var payload = lazy . _payload ;
2047+ var init = lazy . _init ;
19872048 var resolvedModel = init ( payload ) ;
2049+
2050+ {
2051+ var _debugInfo = lazy . _debugInfo ;
2052+
2053+ if ( _debugInfo ) {
2054+ // If this came from Flight, forward any debug info into this new row.
2055+ if ( debugID === null ) {
2056+ // We don't have a chunk to assign debug info. We need to outline this
2057+ // component to assign it an ID.
2058+ return outlineTask ( request , task ) ;
2059+ } else {
2060+ // Forward any debug info we have the first time we see it.
2061+ // We do this after init so that we have received all the debug info
2062+ // from the server by the time we emit it.
2063+ forwardDebugInfo ( request , debugID , _debugInfo ) ;
2064+ }
2065+ }
2066+ }
2067+
19882068 return renderModelDestructive (
19892069 request ,
19902070 task ,
@@ -2310,6 +2390,13 @@ if (__DEV__) {
23102390 request . completedRegularChunks . push ( processedChunk ) ;
23112391 }
23122392
2393+ function forwardDebugInfo ( request , id , debugInfo ) {
2394+ for ( var i = 0 ; i < debugInfo . length ; i ++ ) {
2395+ request . pendingChunks ++ ;
2396+ emitDebugChunk ( request , id , debugInfo [ i ] ) ;
2397+ }
2398+ }
2399+
23132400 var emptyRoot = { } ;
23142401
23152402 function retryTask ( request , task ) {
@@ -2578,7 +2665,9 @@ if (__DEV__) {
25782665 var request = createRequest (
25792666 model ,
25802667 null ,
2581- options ? options . onError : undefined
2668+ options ? options . onError : undefined ,
2669+ undefined ,
2670+ undefined
25822671 ) ;
25832672 startWork ( request ) ;
25842673 startFlowing ( request , destination ) ;
0 commit comments