@@ -79,6 +79,7 @@ import {
7979 logDedupedComponentRender ,
8080 logComponentErrored ,
8181 logIOInfo ,
82+ logComponentAwait ,
8283} from './ReactFlightPerformanceTrack' ;
8384
8485import {
@@ -680,7 +681,7 @@ function getIOInfoTaskName(ioInfo: ReactIOInfo): string {
680681}
681682
682683function getAsyncInfoTaskName(asyncInfo: ReactAsyncInfo): string {
683- return 'await '; // We could be smarter about this and give it a name like `then` or `Promise.all`.
684+ return 'await ' + getIOInfoTaskName ( asyncInfo . awaited ) ;
684685}
685686
686687function getServerComponentTaskName(componentInfo: ReactComponentInfo): string {
@@ -2971,9 +2972,12 @@ function flushComponentPerformance(
29712972 for ( let i = debugInfo . length - 1 ; i >= 0 ; i -- ) {
29722973 const info = debugInfo [ i ] ;
29732974 if ( typeof info . time === 'number' ) {
2974- endTime = info . time ;
2975- if ( endTime > childrenEndTime ) {
2976- childrenEndTime = endTime ;
2975+ if ( info . time > childrenEndTime ) {
2976+ childrenEndTime = info . time ;
2977+ }
2978+ if ( endTime === 0 ) {
2979+ // Last timestamp is the end of the last component.
2980+ endTime = info . time ;
29772981 }
29782982 }
29792983 if ( typeof info . name === 'string' && i > 0 ) {
@@ -3011,8 +3015,29 @@ function flushComponentPerformance(
30113015 }
30123016 // Track the root most component of the result for deduping logging.
30133017 result . component = componentInfo ;
3018+ // Set the end time of the previous component to the start of the previous.
3019+ endTime = startTime ;
30143020 }
30153021 isLastComponent = false ;
3022+ } else if ( info . awaited && i > 0 && i < debugInfo . length - 2 ) {
3023+ // $FlowFixMe: Refined.
3024+ const asyncInfo : ReactAsyncInfo = info ;
3025+ const startTimeInfo = debugInfo [ i - 1 ] ;
3026+ const endTimeInfo = debugInfo [ i + 1 ] ;
3027+ if (
3028+ typeof startTimeInfo . time === 'number' &&
3029+ typeof endTimeInfo . time === 'number'
3030+ ) {
3031+ const awaitStartTime = startTimeInfo . time ;
3032+ const awaitEndTime = endTimeInfo . time ;
3033+ logComponentAwait (
3034+ asyncInfo ,
3035+ trackIdx ,
3036+ awaitStartTime ,
3037+ awaitEndTime ,
3038+ response . _rootEnvironmentName ,
3039+ ) ;
3040+ }
30163041 }
30173042 }
30183043 }
0 commit comments