Skip to content

Commit 8f746a7

Browse files
committed
[Flight] Improve aborted hanging promise stacks
1 parent 7e9699b commit 8f746a7

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

packages/react-server/src/ReactFlightServer.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2291,7 +2291,7 @@ function visitAsyncNode(
22912291
// The technique for debugging the effects of uncached data on the render is to simply uncache it.
22922292
return previousIONode;
22932293
}
2294-
const awaited = node.awaited;
2294+
let awaited = node.awaited;
22952295
let match: void | null | PromiseNode | IONode = previousIONode;
22962296
if (awaited !== null) {
22972297
const ioNode = visitAsyncNode(request, task, awaited, visited, cutOff);
@@ -2324,7 +2324,23 @@ function visitAsyncNode(
23242324
// We aborted this render. If this Promise spanned the abort time it was probably the
23252325
// Promise that was aborted. This won't necessarily have I/O associated with it but
23262326
// it's a point of interest.
2327+
2328+
// If the awaited node was an await in user space, that will typically have a more
2329+
// useful stack. Try to find one, before falling back to using the promise node.
2330+
while (awaited.tag === AWAIT_NODE) {
2331+
if (
2332+
awaited.stack !== null &&
2333+
hasUnfilteredFrame(request, awaited.stack)
2334+
) {
2335+
match = awaited;
2336+
break;
2337+
} else {
2338+
awaited = awaited.awaited;
2339+
}
2340+
}
2341+
23272342
if (
2343+
match === null &&
23282344
node.stack !== null &&
23292345
hasUnfilteredFrame(request, node.stack)
23302346
) {

0 commit comments

Comments
 (0)