Skip to content

Commit a889bb2

Browse files
committed
Use the inner unfiltered Promise's stack as the best stack describing I/O
1 parent 4bef8fa commit a889bb2

File tree

2 files changed

+121
-78
lines changed

2 files changed

+121
-78
lines changed

packages/react-server/src/ReactFlightServer.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1922,14 +1922,17 @@ function visitAsyncNode(
19221922
// We don't log it yet though. We return it to be logged by the point where it's awaited.
19231923
// The ioNode might be another PromiseNode in the case where none of the AwaitNode had
19241924
// unfiltered stacks.
1925-
if (
1925+
if (ioNode.tag === PROMISE_NODE) {
1926+
// If the ioNode was a Promise, then that means we found one in user space since otherwise
1927+
// we would've returned an IO node. We assume this has the best stack.
1928+
match = ioNode;
1929+
} else if (
19261930
filterStackTrace(request, parseStackTrace(node.stack, 1)).length ===
19271931
0
19281932
) {
1929-
// Typically we assume that the outer most Promise that was awaited in user space has the
1930-
// most actionable stack trace for the start of the operation. However, if this Promise
1931-
// was created inside only third party code, then try to use the inner node instead.
1932-
// This could happen if you pass a first party Promise into a third party to be awaited there.
1933+
// If this Promise was created inside only third party code, then try to use
1934+
// the inner I/O node instead. This could happen if third party calls into first
1935+
// party to perform some I/O.
19331936
if (ioNode.end < 0) {
19341937
// If we haven't defined an end time, use the resolve of the outer Promise.
19351938
ioNode.end = node.end;

0 commit comments

Comments
 (0)