@@ -2762,45 +2762,46 @@ function incrementChunkDebugInfo(
27622762 }
27632763}
27642764
2765+ function addDebugInfo ( chunk : SomeChunk < any > , debugInfo : ReactDebugInfo ) : void {
2766+ const value = resolveLazy ( chunk . value ) ;
2767+ if (
2768+ typeof value === 'object' &&
2769+ value !== null &&
2770+ ( isArray ( value ) ||
2771+ typeof value [ ASYNC_ITERATOR ] === 'function' ||
2772+ value . $$typeof === REACT_ELEMENT_TYPE ||
2773+ value . $$typeof === REACT_LAZY_TYPE )
2774+ ) {
2775+ if ( isArray ( value . _debugInfo ) ) {
2776+ // $FlowFixMe[method-unbinding]
2777+ value . _debugInfo . push . apply ( value . _debugInfo , debugInfo ) ;
2778+ } else {
2779+ Object . defineProperty ( ( value : any ) , '_debugInfo' , {
2780+ configurable : false ,
2781+ enumerable : false ,
2782+ writable : true ,
2783+ value : debugInfo ,
2784+ } ) ;
2785+ }
2786+ } else {
2787+ // $FlowFixMe[method-unbinding]
2788+ chunk . _debugInfo . push . apply ( chunk . _debugInfo , debugInfo ) ;
2789+ }
2790+ }
2791+
27652792function resolveChunkDebugInfo(
27662793 streamState: StreamState,
27672794 chunk: SomeChunk< any > ,
27682795): void {
27692796 if ( __DEV__ && enableAsyncDebugInfo ) {
27702797 // Add the currently resolving chunk's debug info representing the stream
27712798 // to the Promise that was waiting on the stream, or its underlying value.
2772- const debugInfoEntry : ReactAsyncInfo = { awaited : streamState . _debugInfo } ;
2773-
2774- const addDebugInfo = ( ) = > {
2775- const value = resolveLazy ( chunk . value ) ;
2776- if (
2777- typeof value === 'object' &&
2778- value !== null &&
2779- ( isArray ( value ) ||
2780- typeof value [ ASYNC_ITERATOR ] === 'function' ||
2781- value . $$typeof === REACT_ELEMENT_TYPE )
2782- ) {
2783- const debugInfo : ReactDebugInfo = [ debugInfoEntry ] ;
2784- if ( isArray ( value . _debugInfo ) ) {
2785- // $FlowFixMe[method-unbinding]
2786- value . _debugInfo . push . apply ( value . _debugInfo , debugInfo ) ;
2787- } else {
2788- Object . defineProperty ( ( value : any ) , '_debugInfo' , {
2789- configurable : false ,
2790- enumerable : false ,
2791- writable : true ,
2792- value : debugInfo ,
2793- } ) ;
2794- }
2795- } else {
2796- chunk . _debugInfo . push ( debugInfoEntry ) ;
2797- }
2798- } ;
2799-
2799+ const debugInfo : ReactDebugInfo = [ { awaited : streamState . _debugInfo } ] ;
28002800 if ( chunk . status === PENDING || chunk . status === BLOCKED ) {
2801- chunk . then ( addDebugInfo , addDebugInfo ) ;
2801+ const boundAddDebugInfo = addDebugInfo . bind ( null , chunk , debugInfo ) ;
2802+ chunk . then ( boundAddDebugInfo , boundAddDebugInfo ) ;
28022803 } else {
2803- addDebugInfo ( ) ;
2804+ addDebugInfo ( chunk , debugInfo ) ;
28042805 }
28052806 }
28062807}
0 commit comments