@@ -692,14 +692,14 @@ function serializeThenable(
692
692
693
693
switch ( thenable . status ) {
694
694
case 'fulfilled ': {
695
- forwardDebugInfoFromThenable ( request , newTask , thenable ) ;
695
+ forwardDebugInfoFromThenable ( request , newTask , thenable , null , null ) ;
696
696
// We have the resolved value, we can go ahead and schedule it for serialization.
697
697
newTask . model = thenable . value ;
698
698
pingTask ( request , newTask ) ;
699
699
return newTask . id ;
700
700
}
701
701
case 'rejected ': {
702
- forwardDebugInfoFromThenable ( request , newTask , thenable ) ;
702
+ forwardDebugInfoFromThenable ( request , newTask , thenable , null , null ) ;
703
703
const x = thenable . reason ;
704
704
erroredTask ( request , newTask , x ) ;
705
705
return newTask . id ;
@@ -1042,11 +1042,11 @@ function createLazyWrapperAroundWakeable(
1042
1042
const thenable : Thenable < mixed > = (wakeable: any);
1043
1043
switch (thenable.status) {
1044
1044
case 'fulfilled' : {
1045
- forwardDebugInfoFromThenable ( request , task , thenable ) ;
1045
+ forwardDebugInfoFromThenable ( request , task , thenable , null , null ) ;
1046
1046
return thenable . value ;
1047
1047
}
1048
1048
case 'rejected' :
1049
- forwardDebugInfoFromThenable ( request , task , thenable ) ;
1049
+ forwardDebugInfoFromThenable ( request , task , thenable , null , null ) ;
1050
1050
break ;
1051
1051
default : {
1052
1052
if ( typeof thenable . status === 'string' ) {
@@ -1366,6 +1366,7 @@ function renderFunctionComponent<Props>(
1366
1366
}
1367
1367
}
1368
1368
} else {
1369
+ componentDebugInfo = ( null : any ) ;
1369
1370
prepareToUseHooksForComponent ( prevThenableState , null ) ;
1370
1371
// The secondArg is always undefined in Server Components since refs error early.
1371
1372
const secondArg = undefined ;
@@ -1398,8 +1399,20 @@ function renderFunctionComponent<Props>(
1398
1399
// We do this at the end so that we don't keep doing this for each retry.
1399
1400
const trackedThenables = getTrackedThenablesAfterRendering ( ) ;
1400
1401
if ( trackedThenables !== null ) {
1402
+ const stacks : Array < Error > =
1403
+ __DEV__ && enableAsyncDebugInfo
1404
+ ? ( trackedThenables : any ) . _stacks ||
1405
+ ( ( trackedThenables : any ) . _stacks = [ ] )
1406
+ : ( null : any ) ;
1401
1407
for ( let i = 0 ; i < trackedThenables . length ; i ++ ) {
1402
- forwardDebugInfoFromThenable ( request , task , trackedThenables [ i ] ) ;
1408
+ const stack = __DEV__ && enableAsyncDebugInfo ? stacks [ i ] : null ;
1409
+ forwardDebugInfoFromThenable (
1410
+ request ,
1411
+ task ,
1412
+ trackedThenables [ i ] ,
1413
+ __DEV__ ? componentDebugInfo : null ,
1414
+ stack ,
1415
+ ) ;
1403
1416
}
1404
1417
}
1405
1418
}
@@ -2019,6 +2032,8 @@ function emitAsyncSequence(
2019
2032
task : Task ,
2020
2033
node : AsyncSequence ,
2021
2034
alreadyForwardedDebugInfo : ?ReactDebugInfo ,
2035
+ owner : null | ReactComponentInfo ,
2036
+ stack : null | Error ,
2022
2037
) : void {
2023
2038
const visited : Set < AsyncSequence | ReactDebugInfo > = new Set ( ) ;
2024
2039
if ( __DEV__ && alreadyForwardedDebugInfo ) {
@@ -2034,10 +2049,21 @@ function emitAsyncSequence(
2034
2049
const env = ( 0 , request . environmentName ) ( ) ;
2035
2050
// If we don't have any thing awaited, the time we started awaiting was internal
2036
2051
// when we yielded after rendering. The current task time is basically that.
2037
- emitDebugChunk ( request , task . id , {
2052
+ const debugInfo : ReactAsyncInfo = {
2038
2053
awaited : ( ( awaitedNode : any ) : ReactIOInfo ) , // This is deduped by this reference.
2039
2054
env : env ,
2040
- } ) ;
2055
+ } ;
2056
+ if ( __DEV__ ) {
2057
+ if ( owner != null ) {
2058
+ // $FlowFixMe[cannot-write]
2059
+ debugInfo . owner = owner ;
2060
+ }
2061
+ if ( stack != null ) {
2062
+ // $FlowFixMe[cannot-write]
2063
+ debugInfo . stack = filterStackTrace ( request , parseStackTrace ( stack , 1 ) ) ;
2064
+ }
2065
+ }
2066
+ emitDebugChunk ( request , task . id , debugInfo ) ;
2041
2067
markOperationEndTime ( request , task , awaitedNode . end ) ;
2042
2068
}
2043
2069
}
@@ -4316,6 +4342,8 @@ function forwardDebugInfoFromThenable(
4316
4342
request : Request ,
4317
4343
task : Task ,
4318
4344
thenable : Thenable < any > ,
4345
+ owner: null | ReactComponentInfo, // DEV-only
4346
+ stack: null | Error, // DEV-only
4319
4347
): void {
4320
4348
let debugInfo : ?ReactDebugInfo ;
4321
4349
if ( __DEV__ ) {
@@ -4332,7 +4360,7 @@ function forwardDebugInfoFromThenable(
4332
4360
) {
4333
4361
const sequence = getAsyncSequenceFromPromise ( thenable ) ;
4334
4362
if ( sequence !== null ) {
4335
- emitAsyncSequence ( request , task , sequence , debugInfo ) ;
4363
+ emitAsyncSequence ( request , task , sequence , debugInfo , owner , stack ) ;
4336
4364
}
4337
4365
}
4338
4366
}
@@ -4357,7 +4385,7 @@ function forwardDebugInfoFromCurrentContext(
4357
4385
) {
4358
4386
const sequence = getCurrentAsyncSequence ( ) ;
4359
4387
if ( sequence !== null ) {
4360
- emitAsyncSequence ( request , task , sequence , debugInfo ) ;
4388
+ emitAsyncSequence ( request , task , sequence , debugInfo , null , null ) ;
4361
4389
}
4362
4390
}
4363
4391
}
0 commit comments