Skip to content

Commit dea84dc

Browse files
committed
[Flight] Only use debug component info for parent stacks
1 parent 3a067e5 commit dea84dc

File tree

2 files changed

+34
-4
lines changed

2 files changed

+34
-4
lines changed

packages/react-client/src/ReactFlightClient.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1794,13 +1794,21 @@ function transferReferencedDebugInfo(
17941794
existingDebugInfo.push.apply(existingDebugInfo, referencedDebugInfo);
17951795
}
17961796
}
1797-
// We also add it to the initializing chunk since the resolution of that promise is
1798-
// also blocked by these. By adding it to both we can track it even if the array/element
1797+
// We also add the debug info to the initializing chunk since the resolution of that promise is
1798+
// also blocked by the referenced debug info. By adding it to both we can track it even if the array/element
17991799
// is extracted, or if the root is rendered as is.
18001800
if (parentChunk !== null) {
18011801
const parentDebugInfo = parentChunk._debugInfo;
1802-
// $FlowFixMe[method-unbinding]
1803-
parentDebugInfo.push.apply(parentDebugInfo, referencedDebugInfo);
1802+
for (let i = 0; i < referencedDebugInfo.length; ++i) {
1803+
const debugInfoEntry = referencedDebugInfo[i];
1804+
if (debugInfoEntry.name != null) {
1805+
(debugInfoEntry: ReactComponentInfo);
1806+
// We're not transferring Component info since we use Component info
1807+
// in Debug info to fill in gaps between Fibers for the parent stack.
1808+
} else {
1809+
parentDebugInfo.push(debugInfoEntry);
1810+
}
1811+
}
18041812
}
18051813
}
18061814
}

packages/react-client/src/__tests__/ReactFlight-test.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2957,6 +2957,12 @@ describe('ReactFlight', () => {
29572957
transport: expect.arrayContaining([]),
29582958
},
29592959
},
2960+
{
2961+
time: 16,
2962+
},
2963+
{
2964+
time: 16,
2965+
},
29602966
{time: 17},
29612967
]
29622968
: undefined,
@@ -2976,6 +2982,12 @@ describe('ReactFlight', () => {
29762982
children: {},
29772983
},
29782984
},
2985+
{
2986+
time: 19,
2987+
},
2988+
{
2989+
time: 19,
2990+
},
29792991
{time: 19},
29802992
]
29812993
: undefined,
@@ -3822,6 +3834,7 @@ describe('ReactFlight', () => {
38223834
expect(ReactNoop).toMatchRenderedOutput(<div>not using props</div>);
38233835
});
38243836

3837+
// @gate __DEV__ && enableComponentPerformanceTrack
38253838
it('produces correct parent stacks', async () => {
38263839
function Container() {
38273840
return ReactServer.createElement('div', null);
@@ -3912,6 +3925,15 @@ describe('ReactFlight', () => {
39123925
{
39133926
"time": 13,
39143927
},
3928+
{
3929+
"time": 14,
3930+
},
3931+
{
3932+
"time": 15,
3933+
},
3934+
{
3935+
"time": 16,
3936+
},
39153937
]
39163938
`);
39173939
} else {

0 commit comments

Comments
 (0)