@@ -278,7 +278,7 @@ function patchConsole(consoleInst: typeof console, methodName: string) {
278
278
request ,
279
279
parseStackTrace ( new Error ( 'react-stack-top-frame' ) , 1 ) ,
280
280
) ;
281
- request . pendingChunks ++ ;
281
+ request . pendingDebugChunks ++ ;
282
282
const owner : null | ReactComponentInfo = resolveOwner ( ) ;
283
283
const args = Array . from ( arguments ) ;
284
284
// Extract the env if this is a console log that was replayed from another env.
@@ -468,6 +468,7 @@ export type Request = {
468
468
timeOrigin : number ,
469
469
abortTime : number ,
470
470
// DEV-only
471
+ pendingDebugChunks : number ,
471
472
completedDebugChunks : Array < Chunk | BinaryChunk > ,
472
473
environmentName : ( ) => string ,
473
474
filterStackFrame : (
@@ -587,6 +588,7 @@ function RequestInstance(
587
588
this.onFatalError = onFatalError;
588
589
589
590
if (__DEV__) {
591
+ this . pendingDebugChunks = 0 ;
590
592
this . completedDebugChunks = ( [ ] : Array < Chunk > ) ;
591
593
this . environmentName =
592
594
environmentName === undefined
@@ -725,7 +727,7 @@ function serializeDebugThenable(
725
727
thenable: Thenable< any > ,
726
728
): string {
727
729
// Like serializeThenable but for renderDebugModel
728
- request . pendingChunks ++ ;
730
+ request . pendingDebugChunks ++ ;
729
731
const id = request . nextChunkId ++ ;
730
732
const ref = serializePromiseID ( id ) ;
731
733
request . writtenDebugObjects . set ( thenable , ref ) ;
@@ -737,20 +739,9 @@ function serializeDebugThenable(
737
739
}
738
740
case 'rejected' : {
739
741
const x = thenable . reason ;
740
- if (
741
- enablePostpone &&
742
- typeof x === 'object' &&
743
- x !== null &&
744
- ( x : any ) . $$typeof === REACT_POSTPONE_TYPE
745
- ) {
746
- const postponeInstance : Postpone = ( x : any ) ;
747
- // We don't log this postpone.
748
- emitPostponeChunk ( request , id , postponeInstance ) ;
749
- } else {
750
- // We don't log these errors since they didn't actually throw into Flight.
751
- const digest = '';
752
- emitErrorChunk ( request , id , digest , x , true ) ;
753
- }
742
+ // We don't log these errors since they didn't actually throw into Flight.
743
+ const digest = '' ;
744
+ emitErrorChunk ( request , id , digest , x , true ) ;
754
745
return ref ;
755
746
}
756
747
}
@@ -787,20 +778,9 @@ function serializeDebugThenable(
787
778
enqueueFlush ( request ) ;
788
779
return ;
789
780
}
790
- if (
791
- enablePostpone &&
792
- typeof reason === 'object ' &&
793
- reason !== null &&
794
- ( reason : any ) . $$typeof === REACT_POSTPONE_TYPE
795
- ) {
796
- const postponeInstance : Postpone = ( reason : any ) ;
797
- // We don't log this postpone.
798
- emitPostponeChunk ( request , id , postponeInstance ) ;
799
- } else {
800
- // We don't log these errors since they didn't actually throw into Flight.
801
- const digest = '' ;
802
- emitErrorChunk ( request , id , digest , reason , true ) ;
803
- }
781
+ // We don't log these errors since they didn't actually throw into Flight.
782
+ const digest = '' ;
783
+ emitErrorChunk ( request , id , digest , reason , true ) ;
804
784
enqueueFlush ( request ) ;
805
785
} ,
806
786
) ;
@@ -1445,7 +1425,7 @@ function renderFunctionComponent<Props>(
1445
1425
const componentName =
1446
1426
( Component : any ) . displayName || Component . name || '' ;
1447
1427
const componentEnv = ( 0 , request . environmentName ) ( ) ;
1448
- request . pendingChunks ++ ;
1428
+ request . pendingDebugChunks ++ ;
1449
1429
componentDebugInfo = ( {
1450
1430
name : componentName ,
1451
1431
env : componentEnv ,
@@ -2219,7 +2199,7 @@ function visitAsyncNode(
2219
2199
const env = ( 0 , request . environmentName ) ( ) ;
2220
2200
advanceTaskTime ( request , task , startTime ) ;
2221
2201
// Then emit a reference to us awaiting it in the current task.
2222
- request . pendingChunks ++ ;
2202
+ request . pendingDebugChunks ++ ;
2223
2203
emitDebugChunk ( request , task . id , {
2224
2204
awaited : ( ( ioNode : any ) : ReactIOInfo ) , // This is deduped by this reference.
2225
2205
env : env ,
@@ -2276,7 +2256,7 @@ function emitAsyncSequence(
2276
2256
} else if (awaitedNode !== null) {
2277
2257
// Nothing in user space (unfiltered stack) awaited this.
2278
2258
serializeIONode ( request , awaitedNode , awaitedNode . promise ) ;
2279
- request . pendingChunks ++ ;
2259
+ request . pendingDebugChunks ++ ;
2280
2260
// We log the environment at the time when we ping which may be later than what the
2281
2261
// environment was when we actually started awaiting.
2282
2262
const env = ( 0 , request . environmentName ) ( ) ;
@@ -2457,7 +2437,7 @@ function serializeDeferredObject(
2457
2437
// This client supports a long lived connection. We can assign this object
2458
2438
// an ID to be lazy loaded later.
2459
2439
// This keeps the connection alive until we ask for it or release it.
2460
- request. pendingChunks ++ ;
2440
+ request. pendingDebugChunks ++ ;
2461
2441
const id = request . nextChunkId ++ ;
2462
2442
deferredDebugObjects . existing . set ( value , id ) ;
2463
2443
deferredDebugObjects . retained . set ( id , value ) ;
@@ -2594,7 +2574,7 @@ function serializeDebugClientReference(
2594
2574
try {
2595
2575
const clientReferenceMetadata : ClientReferenceMetadata =
2596
2576
resolveClientReferenceMetadata ( request . bundlerConfig , clientReference ) ;
2597
- request . pendingChunks ++ ;
2577
+ request . pendingDebugChunks ++ ;
2598
2578
const importId = request . nextChunkId ++ ;
2599
2579
emitImportChunk ( request , importId , clientReferenceMetadata , true ) ;
2600
2580
if ( parent [ 0 ] === REACT_ELEMENT_TYPE && parentPropertyName === '1' ) {
@@ -2607,7 +2587,7 @@ function serializeDebugClientReference(
2607
2587
}
2608
2588
return serializeByValueID ( importId ) ;
2609
2589
} catch ( x ) {
2610
- request . pendingChunks ++ ;
2590
+ request . pendingDebugChunks ++ ;
2611
2591
const errorId = request . nextChunkId ++ ;
2612
2592
const digest = logRecoverableError ( request , x , null ) ;
2613
2593
emitErrorChunk ( request , errorId , digest , x , true ) ;
@@ -2710,7 +2690,7 @@ function serializeLargeTextString(request: Request, text: string): string {
2710
2690
}
2711
2691
2712
2692
function serializeDebugLargeTextString ( request : Request , text : string ) : string {
2713
- request . pendingChunks ++ ;
2693
+ request . pendingDebugChunks ++ ;
2714
2694
const textId = request . nextChunkId ++ ;
2715
2695
emitTextChunk ( request , textId , text , true ) ;
2716
2696
return serializeByValueID ( textId ) ;
@@ -2819,7 +2799,7 @@ function serializeDebugTypedArray(
2819
2799
tag : string ,
2820
2800
typedArray : $ArrayBufferView ,
2821
2801
) : string {
2822
- request . pendingChunks ++ ;
2802
+ request . pendingDebugChunks ++ ;
2823
2803
const bufferId = request . nextChunkId ++ ;
2824
2804
emitTypedArrayChunk ( request , bufferId , tag , typedArray , true ) ;
2825
2805
return serializeByValueID ( bufferId ) ;
@@ -2828,6 +2808,7 @@ function serializeDebugTypedArray(
2828
2808
function serializeDebugBlob ( request : Request , blob : Blob ) : string {
2829
2809
const model : Array < string | Uint8Array > = [ blob . type ] ;
2830
2810
const reader = blob . stream ( ) . getReader ( ) ;
2811
+ request . pendingDebugChunks ++ ;
2831
2812
const id = request . nextChunkId ++ ;
2832
2813
function progress (
2833
2814
entry : { done : false , value : Uint8Array } | { done : true , value : void } ,
@@ -4095,7 +4076,7 @@ function outlineIOInfo(request: Request, ioInfo: ReactIOInfo): void {
4095
4076
return ;
4096
4077
}
4097
4078
// We can't serialize the ConsoleTask/Error objects so we need to omit them before serializing.
4098
- request . pendingChunks ++ ;
4079
+ request . pendingDebugChunks ++ ;
4099
4080
const id = request . nextChunkId ++ ;
4100
4081
const owner = ioInfo . owner ;
4101
4082
// Ensure the owner is already outlined.
@@ -4173,7 +4154,7 @@ function serializeIONode(
4173
4154
request . abortTime
4174
4155
: ioNode . end ;
4175
4156
4176
- request . pendingChunks ++ ;
4157
+ request . pendingDebugChunks ++ ;
4177
4158
const id = request . nextChunkId ++ ;
4178
4159
emitIOInfoChunk (
4179
4160
request ,
@@ -4210,7 +4191,11 @@ function emitTypedArrayChunk(
4210
4191
}
4211
4192
}
4212
4193
}
4213
- request . pendingChunks ++ ; // Extra chunk for the header.
4194
+ if ( debug ) {
4195
+ request . pendingDebugChunks ++ ;
4196
+ } else {
4197
+ request . pendingChunks ++ ; // Extra chunk for the header.
4198
+ }
4214
4199
// TODO: Convert to little endian if that's not the server default.
4215
4200
const binaryChunk = typedArrayToBinaryChunk ( typedArray ) ;
4216
4201
const binaryLength = byteLengthOfBinaryChunk ( binaryChunk ) ;
@@ -4235,7 +4220,11 @@ function emitTextChunk(
4235
4220
'Existence of byteLengthOfChunk should have already been checked. This is a bug in React.' ,
4236
4221
) ;
4237
4222
}
4238
- request . pendingChunks ++ ; // Extra chunk for the header.
4223
+ if ( debug ) {
4224
+ request . pendingDebugChunks ++ ;
4225
+ } else {
4226
+ request . pendingChunks ++ ; // Extra chunk for the header.
4227
+ }
4239
4228
const textChunk = stringToChunk ( text ) ;
4240
4229
const binaryLength = byteLengthOfChunk ( textChunk ) ;
4241
4230
const row = id . toString ( 16 ) + ':T' + binaryLength . toString ( 16 ) + ',' ;
@@ -4620,7 +4609,7 @@ function renderDebugModel(
4620
4609
// $FlowFixMe[method-unbinding]
4621
4610
'(' + Function . prototype . toString . call ( value ) + ')' ,
4622
4611
) ;
4623
- request . pendingChunks ++ ;
4612
+ request . pendingDebugChunks ++ ;
4624
4613
const id = request . nextChunkId ++ ;
4625
4614
const processedChunk = encodeReferenceChunk ( request , id , serializedValue ) ;
4626
4615
request . completedDebugChunks . push ( processedChunk ) ;
@@ -4778,7 +4767,7 @@ function outlineDebugModel(
4778
4767
}
4779
4768
4780
4769
const id = request . nextChunkId ++ ;
4781
- request . pendingChunks ++ ;
4770
+ request . pendingDebugChunks ++ ;
4782
4771
emitOutlinedDebugModelChunk ( request , id , counter , model ) ;
4783
4772
return id ;
4784
4773
}
@@ -4827,7 +4816,7 @@ function emitTimeOriginChunk(request: Request, timeOrigin: number): void {
4827
4816
// We emit the time origin once. All ReactTimeInfo timestamps later in the stream
4828
4817
// are relative to this time origin. This allows for more compact number encoding
4829
4818
// and lower precision loss.
4830
- request .pendingChunks ++ ;
4819
+ request .pendingDebugChunks ++ ;
4831
4820
const row = ':N' + timeOrigin + '\n' ;
4832
4821
const processedChunk = stringToChunk ( row ) ;
4833
4822
// TODO: Move to its own priority queue.
@@ -4854,7 +4843,7 @@ function forwardDebugInfo(
4854
4843
// being no references to this as an owner.
4855
4844
outlineComponentInfo ( request , ( info : any ) ) ;
4856
4845
// Emit a reference to the outlined one.
4857
- request . pendingChunks ++ ;
4846
+ request . pendingDebugChunks ++ ;
4858
4847
emitDebugChunk ( request , id , info ) ;
4859
4848
} else if ( info . awaited ) {
4860
4849
const ioInfo = info . awaited ;
@@ -4895,11 +4884,11 @@ function forwardDebugInfo(
4895
4884
// $FlowFixMe[cannot-write]
4896
4885
debugAsyncInfo . stack = debugStack ;
4897
4886
}
4898
- request . pendingChunks ++ ;
4887
+ request . pendingDebugChunks ++ ;
4899
4888
emitDebugChunk ( request , id , debugAsyncInfo ) ;
4900
4889
}
4901
4890
} else {
4902
- request . pendingChunks ++ ;
4891
+ request . pendingDebugChunks ++ ;
4903
4892
emitDebugChunk ( request , id , info ) ;
4904
4893
}
4905
4894
}
@@ -5001,7 +4990,7 @@ function forwardDebugInfoFromAbortedTask(request: Request, task: Task): void {
5001
4990
// complete in time before aborting.
5002
4991
// The best we can do is try to emit the stack of where this Promise was created.
5003
4992
serializeIONode ( request , node , null ) ;
5004
- request . pendingChunks ++ ;
4993
+ request . pendingDebugChunks ++ ;
5005
4994
const env = ( 0 , request . environmentName ) ( ) ;
5006
4995
const asyncInfo : ReactAsyncInfo = {
5007
4996
awaited : ( ( node : any ) : ReactIOInfo ) , // This is deduped by this reference.
@@ -5030,7 +5019,7 @@ function emitTimingChunk(
5030
5019
if ( ! enableProfilerTimer || ! enableComponentPerformanceTrack ) {
5031
5020
return ;
5032
5021
}
5033
- request . pendingChunks ++ ;
5022
+ request . pendingDebugChunks ++ ;
5034
5023
const relativeTimestamp = timestamp - request . timeOrigin ;
5035
5024
const row =
5036
5025
serializeRowHeader ( 'D' , id ) + '{"time":' + relativeTimestamp + '}\n' ;
@@ -5242,7 +5231,7 @@ function retryTask(request: Request, task: Task): void {
5242
5231
if ( __DEV__ ) {
5243
5232
const currentEnv = ( 0 , request . environmentName ) ( ) ;
5244
5233
if ( currentEnv !== task . environmentName ) {
5245
- request . pendingChunks ++ ;
5234
+ request . pendingDebugChunks ++ ;
5246
5235
// The environment changed since we last emitted any debug information for this
5247
5236
// task. We emit an entry that just includes the environment name change.
5248
5237
emitDebugChunk ( request , task . id , { env : currentEnv } ) ;
@@ -5462,7 +5451,7 @@ function flushCompletedChunks(
5462
5451
const debugChunks = request . completedDebugChunks ;
5463
5452
i = 0 ;
5464
5453
for ( ; i < debugChunks . length ; i ++ ) {
5465
- request . pendingChunks -- ;
5454
+ request . pendingDebugChunks -- ;
5466
5455
const chunk = debugChunks [ i ] ;
5467
5456
const keepWriting : boolean = writeChunkAndReturn ( destination , chunk ) ;
5468
5457
if ( ! keepWriting ) {
@@ -5510,7 +5499,10 @@ function flushCompletedChunks(
5510
5499
completeWriting ( destination ) ;
5511
5500
}
5512
5501
flushBuffered ( destination ) ;
5513
- if ( request . pendingChunks === 0 ) {
5502
+ if (
5503
+ request . pendingChunks === 0 &&
5504
+ ( ! __DEV__ || request . pendingDebugChunks === 0 )
5505
+ ) {
5514
5506
// We're done.
5515
5507
if ( enableTaint ) {
5516
5508
cleanupTaintQueue ( request ) ;
@@ -5729,7 +5721,7 @@ export function resolveDebugMessage(request: Request, message: string): void {
5729
5721
const retainedValue = deferredDebugObjects . retained . get ( id ) ;
5730
5722
if ( retainedValue !== undefined ) {
5731
5723
// We're no longer blocked on this. We won't emit it.
5732
- request . pendingChunks -- ;
5724
+ request . pendingDebugChunks -- ;
5733
5725
deferredDebugObjects . retained . delete ( id ) ;
5734
5726
deferredDebugObjects . existing . delete ( retainedValue ) ;
5735
5727
enqueueFlush ( request ) ;
@@ -5772,7 +5764,7 @@ export function closeDebugChannel(request: Request): void {
5772
5764
) ;
5773
5765
}
5774
5766
deferredDebugObjects . retained . forEach ( ( value , id ) => {
5775
- request . pendingChunks -- ;
5767
+ request . pendingDebugChunks -- ;
5776
5768
deferredDebugObjects . retained . delete ( id ) ;
5777
5769
deferredDebugObjects . existing . delete ( value ) ;
5778
5770
} ) ;
0 commit comments