@@ -73,6 +73,7 @@ import type {ReactElement} from 'shared/ReactElementType';
73
73
import type { LazyComponent } from 'react/src/ReactLazy' ;
74
74
import type {
75
75
AsyncSequence ,
76
+ AwaitNode ,
76
77
IONode ,
77
78
PromiseNode ,
78
79
UnresolvedPromiseNode ,
@@ -2254,7 +2255,7 @@ function visitAsyncNode(
2254
2255
node : AsyncSequence ,
2255
2256
visited : Set < AsyncSequence | ReactDebugInfo > ,
2256
2257
cutOff: number,
2257
- ): void | null | PromiseNode | IONode {
2258
+ ): void | null | PromiseNode | IONode | AwaitNode {
2258
2259
if ( visited . has ( node ) ) {
2259
2260
// It's possible to visit them same node twice when it's part of both an "awaited" path
2260
2261
// and a "previous" path. This also gracefully handles cycles which would be a bug.
@@ -2291,8 +2292,9 @@ function visitAsyncNode(
2291
2292
// The technique for debugging the effects of uncached data on the render is to simply uncache it.
2292
2293
return previousIONode ;
2293
2294
}
2294
- const awaited = node.awaited;
2295
- let match: void | null | PromiseNode | IONode = previousIONode;
2295
+ let awaited = node.awaited;
2296
+ let match: void | null | PromiseNode | IONode | AwaitNode =
2297
+ previousIONode;
2296
2298
if (awaited !== null) {
2297
2299
const ioNode = visitAsyncNode ( request , task , awaited , visited , cutOff ) ;
2298
2300
if ( ioNode === undefined ) {
@@ -2324,7 +2326,23 @@ function visitAsyncNode(
2324
2326
// We aborted this render. If this Promise spanned the abort time it was probably the
2325
2327
// Promise that was aborted. This won't necessarily have I/O associated with it but
2326
2328
// it's a point of interest.
2329
+
2330
+ // If the awaited node was an await in user space, that will typically have a more
2331
+ // useful stack. Try to find one, before falling back to using the promise node.
2332
+ while ( awaited !== null && awaited . tag === AWAIT_NODE ) {
2333
+ if (
2334
+ awaited . stack !== null &&
2335
+ hasUnfilteredFrame ( request , awaited . stack )
2336
+ ) {
2337
+ match = awaited ;
2338
+ break ;
2339
+ } else {
2340
+ awaited = awaited . awaited ;
2341
+ }
2342
+ }
2343
+
2327
2344
if (
2345
+ match === null &&
2328
2346
node . stack !== null &&
2329
2347
hasUnfilteredFrame ( request , node . stack )
2330
2348
) {
@@ -2350,7 +2368,8 @@ function visitAsyncNode(
2350
2368
}
2351
2369
case AWAIT_NODE: {
2352
2370
const awaited = node . awaited ;
2353
- let match : void | null | PromiseNode | IONode = previousIONode ;
2371
+ let match : void | null | PromiseNode | IONode | AwaitNode =
2372
+ previousIONode ;
2354
2373
if ( awaited !== null ) {
2355
2374
const ioNode = visitAsyncNode ( request , task , awaited , visited , cutOff ) ;
2356
2375
if ( ioNode === undefined ) {
@@ -4421,7 +4440,7 @@ function outlineIOInfo(request: Request, ioInfo: ReactIOInfo): void {
4421
4440
4422
4441
function serializeIONode (
4423
4442
request : Request ,
4424
- ioNode : IONode | PromiseNode | UnresolvedPromiseNode ,
4443
+ ioNode : IONode | PromiseNode | UnresolvedPromiseNode | AwaitNode ,
4425
4444
promiseRef : null | WeakRef < Promise < mixed >> ,
4426
4445
) : string {
4427
4446
const existingRef = request . writtenDebugObjects . get ( ioNode ) ;
0 commit comments