@@ -165,7 +165,6 @@ type PendingChunk<T> = {
165
165
status : 'pending' ,
166
166
value : null | Array < ( T ) => mixed > ,
167
167
reason : null | Array < ( mixed ) => mixed > ,
168
- _response : Response ,
169
168
_children : Array < SomeChunk < any >> | ProfilingResult , // Profiling-only
170
169
_debugInfo ?: null | ReactDebugInfo , // DEV-only
171
170
then ( resolve : ( T ) => mixed , reject ?: ( mixed ) => mixed ) : void ,
@@ -174,16 +173,14 @@ type BlockedChunk<T> = {
174
173
status : 'blocked' ,
175
174
value : null | Array < ( T ) => mixed > ,
176
175
reason : null | Array < ( mixed ) => mixed > ,
177
- _response : Response ,
178
176
_children : Array < SomeChunk < any >> | ProfilingResult , // Profiling-only
179
177
_debugInfo ?: null | ReactDebugInfo , // DEV-only
180
178
then ( resolve : ( T ) => mixed , reject ?: ( mixed ) => mixed ) : void ,
181
179
} ;
182
180
type ResolvedModelChunk < T > = {
183
181
status : 'resolved_model' ,
184
182
value : UninitializedModel ,
185
- reason : null ,
186
- _response : Response ,
183
+ reason : Response ,
187
184
_children : Array < SomeChunk < any >> | ProfilingResult , // Profiling-only
188
185
_debugInfo ?: null | ReactDebugInfo , // DEV-only
189
186
then ( resolve : ( T ) => mixed , reject ?: ( mixed ) => mixed ) : void ,
@@ -192,7 +189,6 @@ type ResolvedModuleChunk<T> = {
192
189
status : 'resolved_module' ,
193
190
value : ClientReference < T > ,
194
191
reason : null ,
195
- _response : Response ,
196
192
_children : Array < SomeChunk < any >> | ProfilingResult , // Profiling-only
197
193
_debugInfo ?: null | ReactDebugInfo , // DEV-only
198
194
then ( resolve : ( T ) => mixed , reject ?: ( mixed ) => mixed ) : void ,
@@ -201,7 +197,6 @@ type InitializedChunk<T> = {
201
197
status : 'fulfilled' ,
202
198
value : T ,
203
199
reason : null | FlightStreamController ,
204
- _response : Response ,
205
200
_children : Array < SomeChunk < any >> | ProfilingResult , // Profiling-only
206
201
_debugInfo ?: null | ReactDebugInfo , // DEV-only
207
202
then ( resolve : ( T ) => mixed , reject ?: ( mixed ) => mixed ) : void ,
@@ -212,7 +207,6 @@ type InitializedStreamChunk<
212
207
status : 'fulfilled' ,
213
208
value : T ,
214
209
reason : FlightStreamController ,
215
- _response : Response ,
216
210
_children : Array < SomeChunk < any >> | ProfilingResult , // Profiling-only
217
211
_debugInfo ?: null | ReactDebugInfo , // DEV-only
218
212
then ( resolve : ( ReadableStream ) => mixed , reject ?: ( mixed ) => mixed ) : void ,
@@ -221,7 +215,6 @@ type ErroredChunk<T> = {
221
215
status : 'rejected' ,
222
216
value : null ,
223
217
reason : mixed ,
224
- _response : Response ,
225
218
_children : Array < SomeChunk < any >> | ProfilingResult , // Profiling-only
226
219
_debugInfo ?: null | ReactDebugInfo , // DEV-only
227
220
then ( resolve : ( T ) => mixed , reject ?: ( mixed ) => mixed ) : void ,
@@ -230,7 +223,6 @@ type HaltedChunk<T> = {
230
223
status : 'halted' ,
231
224
value : null ,
232
225
reason : null ,
233
- _response : Response ,
234
226
_children : Array < SomeChunk < any >> | ProfilingResult , // Profiling-only
235
227
_debugInfo ?: null | ReactDebugInfo , // DEV-only
236
228
then ( resolve : ( T ) => mixed , reject ?: ( mixed ) => mixed ) : void ,
@@ -245,16 +237,10 @@ type SomeChunk<T> =
245
237
| HaltedChunk < T > ;
246
238
247
239
// $FlowFixMe[missing-this-annot]
248
- function ReactPromise (
249
- status : any ,
250
- value : any ,
251
- reason : any ,
252
- response : Response ,
253
- ) {
240
+ function ReactPromise ( status : any , value : any , reason : any ) {
254
241
this . status = status ;
255
242
this . value = value ;
256
243
this . reason = reason ;
257
- this . _response = response ;
258
244
if ( enableProfilerTimer && enableComponentPerformanceTrack ) {
259
245
this . _children = [ ] ;
260
246
}
@@ -401,20 +387,20 @@ export function getRoot<T>(response: Response): Thenable<T> {
401
387
402
388
function createPendingChunk< T > (response: Response): PendingChunk< T > {
403
389
// $FlowFixMe[invalid-constructor] Flow doesn't support functions as constructors
404
- return new ReactPromise ( PENDING , null , null , response ) ;
390
+ return new ReactPromise ( PENDING , null , null ) ;
405
391
}
406
392
407
393
function createBlockedChunk< T > (response: Response): BlockedChunk< T > {
408
394
// $FlowFixMe[invalid-constructor] Flow doesn't support functions as constructors
409
- return new ReactPromise ( BLOCKED , null , null , response ) ;
395
+ return new ReactPromise ( BLOCKED , null , null ) ;
410
396
}
411
397
412
398
function createErrorChunk< T > (
413
399
response: Response,
414
400
error: mixed,
415
401
): ErroredChunk< T > {
416
402
// $FlowFixMe[invalid-constructor] Flow doesn't support functions as constructors
417
- return new ReactPromise ( ERRORED , null , error , response ) ;
403
+ return new ReactPromise ( ERRORED , null , error ) ;
418
404
}
419
405
420
406
function wakeChunk< T > (listeners: Array< ( T ) => mixed > , value: T): void {
@@ -486,31 +472,31 @@ function createResolvedModelChunk<T>(
486
472
value: UninitializedModel,
487
473
): ResolvedModelChunk< T > {
488
474
// $FlowFixMe[invalid-constructor] Flow doesn't support functions as constructors
489
- return new ReactPromise ( RESOLVED_MODEL , value , null , response ) ;
475
+ return new ReactPromise ( RESOLVED_MODEL , value , response ) ;
490
476
}
491
477
492
478
function createResolvedModuleChunk< T > (
493
479
response: Response,
494
480
value: ClientReference< T > ,
495
481
): ResolvedModuleChunk< T > {
496
482
// $FlowFixMe[invalid-constructor] Flow doesn't support functions as constructors
497
- return new ReactPromise ( RESOLVED_MODULE , value , null , response ) ;
483
+ return new ReactPromise ( RESOLVED_MODULE , value , null ) ;
498
484
}
499
485
500
486
function createInitializedTextChunk(
501
487
response: Response,
502
488
value: string,
503
489
): InitializedChunk< string > {
504
490
// $FlowFixMe[invalid-constructor] Flow doesn't support functions as constructors
505
- return new ReactPromise ( INITIALIZED , value , null , response ) ;
491
+ return new ReactPromise ( INITIALIZED , value , null ) ;
506
492
}
507
493
508
494
function createInitializedBufferChunk(
509
495
response: Response,
510
496
value: $ArrayBufferView | ArrayBuffer,
511
497
): InitializedChunk< Uint8Array > {
512
498
// $FlowFixMe[invalid-constructor] Flow doesn't support functions as constructors
513
- return new ReactPromise ( INITIALIZED , value , null , response ) ;
499
+ return new ReactPromise ( INITIALIZED , value , null ) ;
514
500
}
515
501
516
502
function createInitializedIteratorResultChunk< T > (
@@ -519,12 +505,7 @@ function createInitializedIteratorResultChunk<T>(
519
505
done: boolean,
520
506
): InitializedChunk< IteratorResult < T , T > > {
521
507
// $FlowFixMe[invalid-constructor] Flow doesn't support functions as constructors
522
- return new ReactPromise (
523
- INITIALIZED ,
524
- { done : done , value : value } ,
525
- null ,
526
- response ,
527
- ) ;
508
+ return new ReactPromise ( INITIALIZED , { done : done , value : value } , null ) ;
528
509
}
529
510
530
511
function createInitializedStreamChunk<
@@ -537,7 +518,7 @@ function createInitializedStreamChunk<
537
518
// We use the reason field to stash the controller since we already have that
538
519
// field. It's a bit of a hack but efficient.
539
520
// $FlowFixMe[invalid-constructor] Flow doesn't support functions as constructors
540
- return new ReactPromise ( INITIALIZED , value , controller , response ) ;
521
+ return new ReactPromise ( INITIALIZED , value , controller ) ;
541
522
}
542
523
543
524
function createResolvedIteratorResultChunk< T > (
@@ -549,21 +530,23 @@ function createResolvedIteratorResultChunk<T>(
549
530
const iteratorResultJSON =
550
531
( done ? '{"done":true,"value":' : '{"done":false,"value":' ) + value + '}' ;
551
532
// $FlowFixMe[invalid-constructor] Flow doesn't support functions as constructors
552
- return new ReactPromise ( RESOLVED_MODEL , iteratorResultJSON , null , response ) ;
533
+ return new ReactPromise ( RESOLVED_MODEL , iteratorResultJSON , response ) ;
553
534
}
554
535
555
536
function resolveIteratorResultChunk< T > (
537
+ response: Response,
556
538
chunk: SomeChunk< IteratorResult < T , T > > ,
557
539
value : UninitializedModel ,
558
540
done : boolean ,
559
541
) : void {
560
542
// To reuse code as much code as possible we add the wrapper element as part of the JSON.
561
543
const iteratorResultJSON =
562
544
( done ? '{"done":true,"value":' : '{"done":false,"value":' ) + value + '}' ;
563
- resolveModelChunk ( chunk , iteratorResultJSON ) ;
545
+ resolveModelChunk ( response , chunk , iteratorResultJSON ) ;
564
546
}
565
547
566
548
function resolveModelChunk< T > (
549
+ response: Response,
567
550
chunk: SomeChunk< T > ,
568
551
value: UninitializedModel,
569
552
): void {
@@ -580,6 +563,7 @@ function resolveModelChunk<T>(
580
563
const resolvedChunk: ResolvedModelChunk< T > = (chunk: any);
581
564
resolvedChunk.status = RESOLVED_MODEL;
582
565
resolvedChunk.value = value;
566
+ resolvedChunk.reason = response;
583
567
if (resolveListeners !== null) {
584
568
// This is unfortunate that we're reading this eagerly if
585
569
// we already have listeners attached since they might no
@@ -625,6 +609,7 @@ function initializeModelChunk<T>(chunk: ResolvedModelChunk<T>): void {
625
609
initializingHandler = null ;
626
610
627
611
const resolvedModel = chunk . value ;
612
+ const response = chunk . reason ;
628
613
629
614
// We go to the BLOCKED state until we've fully resolved this.
630
615
// We do this before parsing in case we try to initialize the same chunk
@@ -639,7 +624,7 @@ function initializeModelChunk<T>(chunk: ResolvedModelChunk<T>): void {
639
624
}
640
625
641
626
try {
642
- const value : T = parseModel ( chunk . _response , resolvedModel ) ;
627
+ const value : T = parseModel ( response , resolvedModel ) ;
643
628
// Invoke any listeners added while resolving this model. I.e. cyclic
644
629
// references. This may or may not fully resolve the model depending on
645
630
// if they were blocked.
@@ -1862,7 +1847,7 @@ function resolveModel(
1862
1847
if ( ! chunk ) {
1863
1848
chunks . set ( id , createResolvedModelChunk ( response , model ) ) ;
1864
1849
} else {
1865
- resolveModelChunk ( chunk , model ) ;
1850
+ resolveModelChunk ( response , chunk , model ) ;
1866
1851
}
1867
1852
}
1868
1853
@@ -2036,7 +2021,7 @@ function startReadableStream<T>(
2036
2021
// to synchronous emitting.
2037
2022
previousBlockedChunk = null ;
2038
2023
}
2039
- resolveModelChunk ( chunk , json ) ;
2024
+ resolveModelChunk ( response , chunk , json ) ;
2040
2025
} ) ;
2041
2026
}
2042
2027
} ,
@@ -2124,7 +2109,12 @@ function startAsyncIterable<T>(
2124
2109
false ,
2125
2110
) ;
2126
2111
} else {
2127
- resolveIteratorResultChunk ( buffer [ nextWriteIndex ] , value , false ) ;
2112
+ resolveIteratorResultChunk (
2113
+ response ,
2114
+ buffer [ nextWriteIndex ] ,
2115
+ value ,
2116
+ false ,
2117
+ ) ;
2128
2118
}
2129
2119
nextWriteIndex ++ ;
2130
2120
} ,
@@ -2137,12 +2127,18 @@ function startAsyncIterable<T>(
2137
2127
true ,
2138
2128
) ;
2139
2129
} else {
2140
- resolveIteratorResultChunk ( buffer [ nextWriteIndex ] , value , true ) ;
2130
+ resolveIteratorResultChunk (
2131
+ response ,
2132
+ buffer [ nextWriteIndex ] ,
2133
+ value ,
2134
+ true ,
2135
+ ) ;
2141
2136
}
2142
2137
nextWriteIndex ++ ;
2143
2138
while ( nextWriteIndex < buffer . length ) {
2144
2139
// In generators, any extra reads from the iterator have the value undefined.
2145
2140
resolveIteratorResultChunk (
2141
+ response ,
2146
2142
buffer [ nextWriteIndex ++ ] ,
2147
2143
'"$undefined"' ,
2148
2144
true ,
@@ -2178,7 +2174,6 @@ function startAsyncIterable<T>(
2178
2174
INITIALIZED ,
2179
2175
{ done : true , value : undefined } ,
2180
2176
null ,
2181
- response ,
2182
2177
) ;
2183
2178
}
2184
2179
buffer [ nextReadIndex ] =
@@ -2946,7 +2941,7 @@ function resolveIOInfo(
2946
2941
chunks . set ( id , chunk ) ;
2947
2942
initializeModelChunk ( chunk ) ;
2948
2943
} else {
2949
- resolveModelChunk ( chunk , model ) ;
2944
+ resolveModelChunk ( response , chunk , model ) ;
2950
2945
if ( chunk . status === RESOLVED_MODEL ) {
2951
2946
initializeModelChunk ( chunk ) ;
2952
2947
}
0 commit comments