@@ -222,13 +222,15 @@ function handleMissedUpdates(
222
222
}
223
223
}
224
224
225
+ type PromiseWithDisplayName = Promise < mixed > & { displayName ?: string } ;
226
+
225
227
function handleMissingClientEdge (
226
228
environment : IEnvironment ,
227
229
parentFragmentNode : ReaderFragment ,
228
230
parentFragmentRef : mixed ,
229
231
missingClientEdgeRequestInfo : MissingClientEdgeRequestInfo ,
230
232
queryOptions ?: FragmentQueryOptions ,
231
- ) : [ QueryResult , ?Promise < mixed > ] {
233
+ ) : [ QueryResult , ?PromiseWithDisplayName ] {
232
234
const originalVariables = getVariablesFromFragment (
233
235
parentFragmentNode ,
234
236
parentFragmentRef ,
@@ -253,10 +255,17 @@ function handleMissingClientEdge(
253
255
queryOptions ?. fetchPolicy ,
254
256
) ;
255
257
256
- return [
257
- queryResult ,
258
- getPromiseForActiveRequest ( environment , queryOperationDescriptor . request ) ,
259
- ] ;
258
+ const promise = getPromiseForActiveRequest (
259
+ environment ,
260
+ queryOperationDescriptor . request ,
261
+ ) ;
262
+ // $FlowExpectedError[prop-missing]
263
+ if ( promise != null && promise . displayName == null ) {
264
+ // $FlowExpectedError[prop-missing]
265
+ promise . displayName = missingClientEdgeRequestInfo . request . params . name ;
266
+ }
267
+ // $FlowFixMe[incompatible-exact] - Intentionally bypassing exactness check
268
+ return [ queryResult , promise ] ;
260
269
}
261
270
262
271
function subscribeToSnapshot (
@@ -490,7 +499,7 @@ hook useFragmentInternal_EXPERIMENTAL(
490
499
const missingClientEdges = getMissingClientEdges ( state ) ;
491
500
// eslint-disable-next-line no-shadow
492
501
let clientEdgeQueries ;
493
- const activeRequestPromises = [ ] ;
502
+ const activeRequestPromises : Array < PromiseWithDisplayName > = [];
494
503
if (missingClientEdges?.length) {
495
504
clientEdgeQueries = ( [ ] : Array < QueryResult > ) ;
496
505
for ( const edge of missingClientEdges ) {
@@ -511,7 +520,12 @@ hook useFragmentInternal_EXPERIMENTAL(
511
520
} , [ state , environment , fragmentNode , fragmentRef , queryOptions ] ) ;
512
521
513
522
if ( activeRequestPromises . length ) {
514
- throw Promise . all ( activeRequestPromises ) ;
523
+ const allPromises = Promise . all ( activeRequestPromises ) ;
524
+ // $FlowExpectedError[prop-missing] Expando to annotate Promises.
525
+ allPromises . displayName = `RelayClientEdge(${ activeRequestPromises
526
+ . map ( promise => promise . displayName )
527
+ . join ( ',' ) } )`;
528
+ throw allPromises ;
515
529
}
516
530
517
531
// See above note
@@ -538,12 +552,15 @@ hook useFragmentInternal_EXPERIMENTAL(
538
552
// Suspend if a Live Resolver within this fragment is in a suspended state:
539
553
const suspendingLiveResolvers = getSuspendingLiveResolver ( state ) ;
540
554
if ( suspendingLiveResolvers != null && suspendingLiveResolvers . length > 0 ) {
541
- throw Promise . all (
555
+ const promise = Promise . all (
542
556
suspendingLiveResolvers . map ( liveStateID => {
543
557
// $FlowFixMe[prop-missing] This is expected to be a RelayModernStore
544
558
return environment . getStore ( ) . getLiveResolverPromise ( liveStateID ) ;
545
559
} ) ,
546
560
) ;
561
+ // $FlowExpectedError[prop-missing] Expando to annotate Promises.
562
+ promise . displayName = 'RelayLiveResolver(' + fragmentNode . name + ')' ;
563
+ throw promise ;
547
564
}
548
565
// Suspend if an active operation bears on this fragment, either the
549
566
// fragment's owner or some other mutation etc. that could affect it.
0 commit comments