@@ -13,6 +13,7 @@ import type {
1313 ReactComponentInfo ,
1414 ReactEnvironmentInfo ,
1515 ReactAsyncInfo ,
16+ ReactIOInfo ,
1617 ReactTimeInfo ,
1718 ReactStackTrace ,
1819 ReactFunctionLocation ,
@@ -673,6 +674,14 @@ function nullRefGetter() {
673674 }
674675}
675676
677+ function getIOInfoTaskName ( ioInfo : ReactIOInfo ) : string {
678+ return ''; // TODO
679+ }
680+
681+ function getAsyncInfoTaskName(asyncInfo: ReactAsyncInfo): string {
682+ return 'await '; // We could be smarter about this and give it a name like `then` or `Promise.all`.
683+ }
684+
676685function getServerComponentTaskName(componentInfo: ReactComponentInfo): string {
677686 return '<' + ( componentInfo . name || '...' ) + '>' ;
678687}
@@ -2448,30 +2457,27 @@ function getRootTask(
24482457
24492458function initializeFakeTask(
24502459 response: Response,
2451- debugInfo: ReactComponentInfo | ReactAsyncInfo,
2460+ debugInfo: ReactComponentInfo | ReactAsyncInfo | ReactIOInfo ,
24522461 childEnvironmentName: string,
24532462): null | ConsoleTask {
24542463 if ( ! supportsCreateTask ) {
24552464 return null ;
24562465 }
2457- const componentInfo: ReactComponentInfo = (debugInfo: any); // Refined
24582466 if (debugInfo.stack == null) {
24592467 // If this is an error, we should've really already initialized the task.
24602468 // If it's null, we can't initialize a task.
24612469 return null ;
24622470 }
24632471 const stack = debugInfo.stack;
24642472 const env: string =
2465- componentInfo.env == null
2466- ? response._rootEnvironmentName
2467- : componentInfo.env;
2473+ debugInfo.env == null ? response._rootEnvironmentName : debugInfo.env;
24682474 if (env !== childEnvironmentName) {
24692475 // This is the boundary between two environments so we'll annotate the task name.
24702476 // That is unusual so we don't cache it.
24712477 const ownerTask =
2472- componentInfo . owner == null
2478+ debugInfo . owner == null
24732479 ? null
2474- : initializeFakeTask ( response , componentInfo . owner , env ) ;
2480+ : initializeFakeTask ( response , debugInfo . owner , env ) ;
24752481 return buildFakeTask (
24762482 response ,
24772483 ownerTask ,
@@ -2480,20 +2486,27 @@ function initializeFakeTask(
24802486 env ,
24812487 ) ;
24822488 } else {
2483- const cachedEntry = componentInfo . debugTask ;
2489+ const cachedEntry = debugInfo . debugTask ;
24842490 if ( cachedEntry !== undefined ) {
24852491 return cachedEntry ;
24862492 }
24872493 const ownerTask =
2488- componentInfo . owner == null
2494+ debugInfo . owner == null
24892495 ? null
2490- : initializeFakeTask ( response , componentInfo . owner , env ) ;
2496+ : initializeFakeTask ( response , debugInfo . owner , env ) ;
2497+ // Some unfortunate pattern matching to refine the type.
2498+ const taskName =
2499+ debugInfo . key !== undefined
2500+ ? getServerComponentTaskName ( ( ( debugInfo : any ) : ReactComponentInfo ) )
2501+ : debugInfo . name !== undefined
2502+ ? getIOInfoTaskName ( ( ( debugInfo : any ) : ReactIOInfo ) )
2503+ : getAsyncInfoTaskName ( ( ( debugInfo : any ) : ReactAsyncInfo ) ) ;
24912504 // $FlowFixMe[cannot-write]: We consider this part of initialization.
2492- return ( componentInfo . debugTask = buildFakeTask (
2505+ return ( debugInfo . debugTask = buildFakeTask (
24932506 response ,
24942507 ownerTask ,
24952508 stack ,
2496- getServerComponentTaskName ( componentInfo ) ,
2509+ taskName ,
24972510 env ,
24982511 ) ) ;
24992512 }
@@ -2556,7 +2569,7 @@ function fakeJSXCallSite() {
25562569
25572570function initializeFakeStack(
25582571 response: Response,
2559- debugInfo: ReactComponentInfo | ReactAsyncInfo,
2572+ debugInfo: ReactComponentInfo | ReactAsyncInfo | ReactIOInfo ,
25602573): void {
25612574 const cachedEntry = debugInfo . debugStack ;
25622575 if ( cachedEntry !== undefined ) {
@@ -2741,6 +2754,23 @@ function resolveConsoleEntry(
27412754 );
27422755}
27432756
2757+ function initializeIOInfo ( response : Response , ioInfo : ReactIOInfo ) : void {
2758+ const env =
2759+ // TODO: Pass env through I/O info.
2760+ // ioInfo.env !== undefined ? ioInfo.env :
2761+ response . _rootEnvironmentName ;
2762+ if ( ioInfo . stack !== undefined ) {
2763+ initializeFakeTask ( response , ioInfo , env ) ;
2764+ initializeFakeStack ( response , ioInfo ) ;
2765+ }
2766+ // TODO: Initialize owner.
2767+ // Adjust the time to the current environment's time space.
2768+ // $FlowFixMe[cannot-write]
2769+ ioInfo.start += response._timeOrigin;
2770+ // $FlowFixMe[cannot-write]
2771+ ioInfo.end += response._timeOrigin;
2772+ }
2773+
27442774function resolveIOInfo (
27452775 response : Response ,
27462776 id : number ,
@@ -2759,11 +2789,11 @@ function resolveIOInfo(
27592789 }
27602790 }
27612791 if ( chunk . status === INITIALIZED ) {
2762- // TODO: Log.
2792+ initializeIOInfo ( response , chunk . value ) ;
27632793 } else {
27642794 chunk . then (
27652795 v => {
2766- // TODO: Log.
2796+ initializeIOInfo ( response , v ) ;
27672797 } ,
27682798 e => {
27692799 // Ignore debug info errors for now. Unnecessary noise.
0 commit comments