Skip to content

Commit a1b1c56

Browse files
committed
Track owner on AsyncSequence nodes
1 parent 8e094d5 commit a1b1c56

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

packages/react-server/src/ReactFlightAsyncSequence.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,15 @@
77
* @flow
88
*/
99

10+
import type {ReactComponentInfo} from 'shared/ReactTypes';
11+
1012
export const IO_NODE = 0;
1113
export const PROMISE_NODE = 1;
1214
export const AWAIT_NODE = 2;
1315

1416
export type IONode = {
1517
tag: 0,
18+
owner: null | ReactComponentInfo,
1619
stack: Error, // callsite that spawned the I/O
1720
start: number, // start time when the first part of the I/O sequence started
1821
end: number, // we typically don't use this. only when there's no promise intermediate.
@@ -22,6 +25,7 @@ export type IONode = {
2225

2326
export type PromiseNode = {
2427
tag: 1,
28+
owner: null | ReactComponentInfo,
2529
stack: Error, // callsite that created the Promise
2630
start: number, // start time when the Promise was created
2731
end: number, // end time when the Promise was resolved.
@@ -31,6 +35,7 @@ export type PromiseNode = {
3135

3236
export type AwaitNode = {
3337
tag: 2,
38+
owner: null | ReactComponentInfo,
3439
stack: Error, // callsite that awaited (using await, .then(), Promise.all(), ...)
3540
start: -1.1, // not used. We use the timing of the awaited promise.
3641
end: -1.1, // not used.

packages/react-server/src/ReactFlightServer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3627,7 +3627,7 @@ function serializeIONode(
36273627
name = name.slice(7);
36283628
}
36293629
}
3630-
const owner = null; // TODO
3630+
const owner = ioNode.owner;
36313631
// Ensure the owner is already outlined.
36323632
if (owner != null) {
36333633
outlineComponentInfo(request, owner);

packages/react-server/src/ReactFlightServerConfigDebugNode.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import type {
1515
} from './ReactFlightAsyncSequence';
1616

1717
import {IO_NODE, PROMISE_NODE, AWAIT_NODE} from './ReactFlightAsyncSequence';
18+
import {resolveOwner} from './flight/ReactFlightCurrentOwner';
1819
import {createHook, executionAsyncId} from 'async_hooks';
1920
import {enableAsyncDebugInfo} from 'shared/ReactFeatureFlags';
2021

@@ -46,6 +47,7 @@ export function initAsyncDebugInfo(): void {
4647
// so that we can later pick the best stack trace in user space.
4748
node = ({
4849
tag: AWAIT_NODE,
50+
owner: resolveOwner(),
4951
stack: new Error(),
5052
start: -1.1,
5153
end: -1.1,
@@ -55,6 +57,7 @@ export function initAsyncDebugInfo(): void {
5557
} else {
5658
node = ({
5759
tag: PROMISE_NODE,
60+
owner: resolveOwner(),
5861
stack: new Error(),
5962
start: performance.now(),
6063
end: -1.1, // Set when we resolve.
@@ -74,6 +77,7 @@ export function initAsyncDebugInfo(): void {
7477
// We have begun a new I/O sequence.
7578
node = ({
7679
tag: IO_NODE,
80+
owner: resolveOwner(),
7781
stack: new Error(), // This is only used if no native promises are used.
7882
start: performance.now(),
7983
end: -1.1, // Only set when pinged.
@@ -84,6 +88,7 @@ export function initAsyncDebugInfo(): void {
8488
// We have begun a new I/O sequence after the await.
8589
node = ({
8690
tag: IO_NODE,
91+
owner: resolveOwner(),
8792
stack: new Error(),
8893
start: performance.now(),
8994
end: -1.1, // Only set when pinged.

0 commit comments

Comments
 (0)