Skip to content

Commit fe5fefc

Browse files
committed
Don't add undefined properties when forwarding
Maybe we should keep the nulls.
1 parent b2db1ec commit fe5fefc

File tree

6 files changed

+60
-74
lines changed

6 files changed

+60
-74
lines changed

packages/react-client/src/ReactFlightClient.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2658,7 +2658,7 @@ function resolveDebugInfo(
26582658
// to initialize it when we need it, we might be inside user code.
26592659
initializeFakeTask(response, componentInfoOrAsyncInfo);
26602660
}
2661-
if (debugInfo.owner === null && response._debugRootOwner != null) {
2661+
if (debugInfo.owner == null && response._debugRootOwner != null) {
26622662
const componentInfoOrAsyncInfo: ReactComponentInfo | ReactAsyncInfo =
26632663
// $FlowFixMe: By narrowing `owner` to `null`, we narrowed `debugInfo` to `ReactComponentInfo`
26642664
debugInfo;

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

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,6 @@ describe('ReactFlight', () => {
320320
name: 'Greeting',
321321
env: 'Server',
322322
key: null,
323-
owner: null,
324323
stack: ' in Object.<anonymous> (at **)',
325324
props: {
326325
firstName: 'Seb',
@@ -364,7 +363,6 @@ describe('ReactFlight', () => {
364363
name: 'Greeting',
365364
env: 'Server',
366365
key: null,
367-
owner: null,
368366
stack: ' in Object.<anonymous> (at **)',
369367
props: {
370368
firstName: 'Seb',
@@ -2812,7 +2810,6 @@ describe('ReactFlight', () => {
28122810
name: 'ServerComponent',
28132811
env: 'Server',
28142812
key: null,
2815-
owner: null,
28162813
stack: ' in Object.<anonymous> (at **)',
28172814
props: {
28182815
transport: expect.arrayContaining([]),
@@ -2834,7 +2831,6 @@ describe('ReactFlight', () => {
28342831
name: 'ThirdPartyComponent',
28352832
env: 'third-party',
28362833
key: null,
2837-
owner: null,
28382834
stack: ' in Object.<anonymous> (at **)',
28392835
props: {},
28402836
},
@@ -2851,7 +2847,6 @@ describe('ReactFlight', () => {
28512847
name: 'ThirdPartyLazyComponent',
28522848
env: 'third-party',
28532849
key: null,
2854-
owner: null,
28552850
stack: ' in myLazy (at **)\n in lazyInitializer (at **)',
28562851
props: {},
28572852
},
@@ -2867,7 +2862,6 @@ describe('ReactFlight', () => {
28672862
name: 'ThirdPartyFragmentComponent',
28682863
env: 'third-party',
28692864
key: '3',
2870-
owner: null,
28712865
stack: ' in Object.<anonymous> (at **)',
28722866
props: {},
28732867
},
@@ -2941,7 +2935,6 @@ describe('ReactFlight', () => {
29412935
name: 'ServerComponent',
29422936
env: 'Server',
29432937
key: null,
2944-
owner: null,
29452938
stack: ' in Object.<anonymous> (at **)',
29462939
props: {
29472940
transport: expect.arrayContaining([]),
@@ -2961,7 +2954,6 @@ describe('ReactFlight', () => {
29612954
name: 'Keyed',
29622955
env: 'Server',
29632956
key: 'keyed',
2964-
owner: null,
29652957
stack: ' in ServerComponent (at **)',
29662958
props: {
29672959
children: {},
@@ -2980,7 +2972,6 @@ describe('ReactFlight', () => {
29802972
name: 'ThirdPartyAsyncIterableComponent',
29812973
env: 'third-party',
29822974
key: null,
2983-
owner: null,
29842975
stack: ' in Object.<anonymous> (at **)',
29852976
props: {},
29862977
},
@@ -3137,7 +3128,6 @@ describe('ReactFlight', () => {
31373128
name: 'Component',
31383129
env: 'A',
31393130
key: null,
3140-
owner: null,
31413131
stack: ' in Object.<anonymous> (at **)',
31423132
props: {},
31433133
},
@@ -3325,7 +3315,6 @@ describe('ReactFlight', () => {
33253315
name: 'Greeting',
33263316
env: 'Server',
33273317
key: null,
3328-
owner: null,
33293318
stack: ' in Object.<anonymous> (at **)',
33303319
props: {
33313320
firstName: 'Seb',

packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMBrowser-test.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,6 @@ describe('ReactFlightDOMBrowser', () => {
708708
name: 'Server',
709709
env: 'Server',
710710
key: null,
711-
owner: null,
712711
}),
713712
}),
714713
);
@@ -724,7 +723,6 @@ describe('ReactFlightDOMBrowser', () => {
724723
name: 'Server',
725724
env: 'Server',
726725
key: null,
727-
owner: null,
728726
}),
729727
}),
730728
);

packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMEdge-test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1190,7 +1190,6 @@ describe('ReactFlightDOMEdge', () => {
11901190
const greetInfo = expect.objectContaining({
11911191
name: 'Greeting',
11921192
env: 'Server',
1193-
owner: null,
11941193
});
11951194
expect(lazyWrapper._debugInfo).toEqual([
11961195
{time: 12},

packages/react-server/src/ReactFlightServer.js

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3587,18 +3587,24 @@ function outlineComponentInfo(
35873587
'debugTask' | 'debugStack',
35883588
> = {
35893589
name: componentInfo.name,
3590-
env: componentInfo.env,
35913590
key: componentInfo.key,
3592-
owner: componentInfo.owner,
35933591
};
3592+
if (componentInfo.env != null) {
3593+
// $FlowFixMe[cannot-write]
3594+
componentDebugInfo.env = componentInfo.env;
3595+
}
3596+
if (componentInfo.owner != null) {
3597+
// $FlowFixMe[cannot-write]
3598+
componentDebugInfo.owner = componentInfo.owner;
3599+
}
35943600
if (componentInfo.stack == null && componentInfo.debugStack != null) {
35953601
// If we have a debugStack but no parsed stack we should parse it.
35963602
// $FlowFixMe[cannot-write]
35973603
componentDebugInfo.stack = filterStackTrace(
35983604
request,
35993605
parseStackTrace(componentInfo.debugStack, 1),
36003606
);
3601-
} else {
3607+
} else if (componentInfo.stack != null) {
36023608
// $FlowFixMe[cannot-write]
36033609
componentDebugInfo.stack = componentInfo.stack;
36043610
}
@@ -4293,10 +4299,19 @@ function forwardDebugInfo(
42934299
const debugAsyncInfo: Omit<ReactAsyncInfo, 'debugTask' | 'debugStack'> =
42944300
{
42954301
awaited: ioInfo,
4296-
env: info.env,
4297-
owner: info.owner,
4298-
stack: debugStack,
42994302
};
4303+
if (info.env != null) {
4304+
// $FlowFixMe[cannot-write]
4305+
debugAsyncInfo.env = info.env;
4306+
}
4307+
if (info.owner != null) {
4308+
// $FlowFixMe[cannot-write]
4309+
debugAsyncInfo.owner = info.owner;
4310+
}
4311+
if (debugStack != null) {
4312+
// $FlowFixMe[cannot-write]
4313+
debugAsyncInfo.stack = debugStack;
4314+
}
43004315
emitDebugChunk(request, id, debugAsyncInfo);
43014316
} else {
43024317
emitDebugChunk(request, id, debugInfo[i]);

0 commit comments

Comments
 (0)