Skip to content

Commit 4ca97e4

Browse files
authored
Clean up enableSiblingPrerendering flag (facebook#32319)
1 parent 9b79292 commit 4ca97e4

File tree

46 files changed

+866
-1178
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+866
-1178
lines changed

packages/react-cache/src/__tests__/ReactCacheOld-test.internal.js

Lines changed: 35 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ describe('ReactCache', () => {
126126
await waitForAll([
127127
'Suspend! [Hi]',
128128
'Loading...',
129-
130-
...(gate('enableSiblingPrerendering') ? ['Suspend! [Hi]'] : []),
129+
// pre-warming
130+
'Suspend! [Hi]',
131131
]);
132132

133133
jest.advanceTimersByTime(100);
@@ -150,8 +150,8 @@ describe('ReactCache', () => {
150150
await waitForAll([
151151
'Suspend! [Hi]',
152152
'Loading...',
153-
154-
...(gate('enableSiblingPrerendering') ? ['Suspend! [Hi]'] : []),
153+
// pre-warming
154+
'Suspend! [Hi]',
155155
]);
156156

157157
textResourceShouldFail = true;
@@ -195,36 +195,33 @@ describe('ReactCache', () => {
195195
await waitForAll([
196196
'App',
197197
'Loading...',
198-
199-
...(gate('enableSiblingPrerendering') ? ['App'] : []),
198+
// pre-warming
199+
'App',
200200
]);
201201
assertConsoleErrorDev([
202202
'Invalid key type. Expected a string, number, symbol, or ' +
203203
"boolean, but instead received: [ 'Hi', 100 ]\n\n" +
204204
'To use non-primitive values as keys, you must pass a hash ' +
205205
'function as the second argument to createResource().\n' +
206206
' in App (at **)',
207-
...(gate('enableSiblingPrerendering')
208-
? [
209-
'Invalid key type. Expected a string, number, symbol, or ' +
210-
"boolean, but instead received: [ 'Hi', 100 ]\n\n" +
211-
'To use non-primitive values as keys, you must pass a hash ' +
212-
'function as the second argument to createResource().\n' +
213-
' in App (at **)',
214-
]
215-
: []),
207+
208+
// pre-warming
209+
'Invalid key type. Expected a string, number, symbol, or ' +
210+
"boolean, but instead received: [ 'Hi', 100 ]\n\n" +
211+
'To use non-primitive values as keys, you must pass a hash ' +
212+
'function as the second argument to createResource().\n' +
213+
' in App (at **)',
216214
]);
217215
} else {
218216
await waitForAll([
219217
'App',
220218
'Loading...',
221-
222-
...(gate('enableSiblingPrerendering') ? ['App'] : []),
219+
// pre-warming
220+
'App',
223221
]);
224222
}
225223
});
226224

227-
// @gate enableSiblingPrerendering
228225
it('evicts least recently used values', async () => {
229226
ReactCache.unstable_setGlobalCacheLimit(3);
230227

@@ -240,15 +237,28 @@ describe('ReactCache', () => {
240237
await waitForPaint(['Suspend! [1]', 'Loading...']);
241238
jest.advanceTimersByTime(100);
242239
assertLog(['Promise resolved [1]']);
243-
await waitForAll([1, 'Suspend! [2]']);
240+
await waitForAll([
241+
1,
242+
'Suspend! [2]',
243+
...(gate('alwaysThrottleRetries')
244+
? []
245+
: [1, 'Suspend! [2]', 'Suspend! [3]']),
246+
]);
244247

245248
jest.advanceTimersByTime(100);
246-
assertLog(['Promise resolved [2]']);
247-
await waitForAll([1, 2, 'Suspend! [3]']);
249+
assertLog([
250+
'Promise resolved [2]',
251+
...(gate('alwaysThrottleRetries') ? [] : ['Promise resolved [3]']),
252+
]);
253+
await waitForAll([
254+
1,
255+
2,
256+
...(gate('alwaysThrottleRetries') ? ['Suspend! [3]'] : [3]),
257+
]);
248258

249259
jest.advanceTimersByTime(100);
250-
assertLog(['Promise resolved [3]']);
251-
await waitForAll([1, 2, 3]);
260+
assertLog(gate('alwaysThrottleRetries') ? ['Promise resolved [3]'] : []);
261+
await waitForAll(gate('alwaysThrottleRetries') ? [1, 2, 3] : []);
252262

253263
await act(() => jest.advanceTimersByTime(100));
254264
expect(root).toMatchRenderedOutput('123');
@@ -378,8 +388,8 @@ describe('ReactCache', () => {
378388
await waitForAll([
379389
'Suspend! [Hi]',
380390
'Loading...',
381-
382-
...(gate('enableSiblingPrerendering') ? ['Suspend! [Hi]'] : []),
391+
// pre-warming
392+
'Suspend! [Hi]',
383393
]);
384394

385395
resolveThenable('Hi');

packages/react-devtools-shared/src/__tests__/TimelineProfiler-test.js

Lines changed: 9 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,11 @@ import {
1515
normalizeCodeLocInfo,
1616
} from './utils';
1717

18-
import {ReactVersion} from '../../../../ReactVersions';
19-
import semver from 'semver';
20-
2118
let React = require('react');
2219
let Scheduler;
2320
let store;
2421
let utils;
2522

26-
// TODO: This is how other DevTools tests access the version but we should find
27-
// a better solution for this
28-
const ReactVersionTestingAgainst = process.env.REACT_VERSION || ReactVersion;
29-
// Disabling this while the flag is off in experimental. Leaving the logic so we can
30-
// restore the behavior when we turn the flag back on.
31-
const enableSiblingPrerendering =
32-
false && semver.gte(ReactVersionTestingAgainst, '19.0.0');
33-
3423
// This flag is on experimental which disables timeline profiler.
3524
const enableComponentPerformanceTrack =
3625
React.version.startsWith('19') && React.version.includes('experimental');
@@ -1678,8 +1667,8 @@ describe('Timeline profiler', () => {
16781667

16791668
await waitForAll([
16801669
'suspended',
1681-
1682-
...(enableSiblingPrerendering ? ['suspended'] : []),
1670+
// pre-warming
1671+
'suspended',
16831672
]);
16841673

16851674
Scheduler.unstable_advanceTime(10);
@@ -1691,8 +1680,7 @@ describe('Timeline profiler', () => {
16911680
const timelineData = stopProfilingAndGetTimelineData();
16921681

16931682
// Verify the Suspense event and duration was recorded.
1694-
if (enableSiblingPrerendering) {
1695-
expect(timelineData.suspenseEvents).toMatchInlineSnapshot(`
1683+
expect(timelineData.suspenseEvents).toMatchInlineSnapshot(`
16961684
[
16971685
{
16981686
"componentName": "Example",
@@ -1720,29 +1708,11 @@ describe('Timeline profiler', () => {
17201708
},
17211709
]
17221710
`);
1723-
} else {
1724-
const suspenseEvent = timelineData.suspenseEvents[0];
1725-
expect(suspenseEvent).toMatchInlineSnapshot(`
1726-
{
1727-
"componentName": "Example",
1728-
"depth": 0,
1729-
"duration": 10,
1730-
"id": "0",
1731-
"phase": "mount",
1732-
"promiseName": "",
1733-
"resolution": "resolved",
1734-
"timestamp": 10,
1735-
"type": "suspense",
1736-
"warning": null,
1737-
}
1738-
`);
1739-
}
17401711

17411712
// There should be two batches of renders: Suspeneded and resolved.
17421713
expect(timelineData.batchUIDToMeasuresMap.size).toBe(2);
1743-
expect(timelineData.componentMeasures).toHaveLength(
1744-
enableSiblingPrerendering ? 3 : 2,
1745-
);
1714+
// An additional measure with pre-warming
1715+
expect(timelineData.componentMeasures).toHaveLength(3);
17461716
});
17471717

17481718
it('should mark concurrent render with suspense that rejects', async () => {
@@ -1769,11 +1739,7 @@ describe('Timeline profiler', () => {
17691739
</React.Suspense>,
17701740
);
17711741

1772-
await waitForAll([
1773-
'suspended',
1774-
1775-
...(enableSiblingPrerendering ? ['suspended'] : []),
1776-
]);
1742+
await waitForAll(['suspended', 'suspended']);
17771743

17781744
Scheduler.unstable_advanceTime(10);
17791745
rejectFn();
@@ -1784,8 +1750,7 @@ describe('Timeline profiler', () => {
17841750
const timelineData = stopProfilingAndGetTimelineData();
17851751

17861752
// Verify the Suspense event and duration was recorded.
1787-
if (enableSiblingPrerendering) {
1788-
expect(timelineData.suspenseEvents).toMatchInlineSnapshot(`
1753+
expect(timelineData.suspenseEvents).toMatchInlineSnapshot(`
17891754
[
17901755
{
17911756
"componentName": "Example",
@@ -1813,30 +1778,11 @@ describe('Timeline profiler', () => {
18131778
},
18141779
]
18151780
`);
1816-
} else {
1817-
expect(timelineData.suspenseEvents).toHaveLength(1);
1818-
const suspenseEvent = timelineData.suspenseEvents[0];
1819-
expect(suspenseEvent).toMatchInlineSnapshot(`
1820-
{
1821-
"componentName": "Example",
1822-
"depth": 0,
1823-
"duration": 10,
1824-
"id": "0",
1825-
"phase": "mount",
1826-
"promiseName": "",
1827-
"resolution": "rejected",
1828-
"timestamp": 10,
1829-
"type": "suspense",
1830-
"warning": null,
1831-
}
1832-
`);
1833-
}
18341781

18351782
// There should be two batches of renders: Suspeneded and resolved.
18361783
expect(timelineData.batchUIDToMeasuresMap.size).toBe(2);
1837-
expect(timelineData.componentMeasures).toHaveLength(
1838-
enableSiblingPrerendering ? 3 : 2,
1839-
);
1784+
// An additional measure with pre-warming
1785+
expect(timelineData.componentMeasures).toHaveLength(3);
18401786
});
18411787

18421788
it('should mark cascading class component state updates', async () => {

packages/react-dom/src/__tests__/ReactDOMFiberAsync-test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,8 @@ describe('ReactDOMFiberAsync', () => {
751751
// Because it suspended, it remains on the current path
752752
expect(div.textContent).toBe('/path/a');
753753
});
754-
assertLog(gate('enableSiblingPrerendering') ? ['Suspend! [/path/b]'] : []);
754+
// pre-warming
755+
assertLog(['Suspend! [/path/b]']);
755756

756757
await act(async () => {
757758
resolvePromise();

packages/react-dom/src/__tests__/ReactDOMForm-test.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1437,8 +1437,8 @@ describe('ReactDOMForm', () => {
14371437
assertLog([
14381438
'Suspend! [Count: 0]',
14391439
'Loading...',
1440-
1441-
...(gate('enableSiblingPrerendering') ? ['Suspend! [Count: 0]'] : []),
1440+
// pre-warming
1441+
'Suspend! [Count: 0]',
14421442
]);
14431443
await act(() => resolveText('Count: 0'));
14441444
assertLog(['Count: 0']);
@@ -1448,8 +1448,8 @@ describe('ReactDOMForm', () => {
14481448
assertLog([
14491449
'Suspend! [Count: 1]',
14501450
'Loading...',
1451-
1452-
...(gate('enableSiblingPrerendering') ? ['Suspend! [Count: 1]'] : []),
1451+
// pre-warming
1452+
'Suspend! [Count: 1]',
14531453
]);
14541454
expect(container.textContent).toBe('Loading...');
14551455

@@ -1482,8 +1482,8 @@ describe('ReactDOMForm', () => {
14821482
await act(() => root.render(<App />));
14831483
assertLog([
14841484
'Suspend! [Count: 0]',
1485-
1486-
...(gate('enableSiblingPrerendering') ? ['Suspend! [Count: 0]'] : []),
1485+
// pre-warming
1486+
'Suspend! [Count: 0]',
14871487
]);
14881488
await act(() => resolveText('Count: 0'));
14891489
assertLog(['Count: 0']);
@@ -1501,8 +1501,8 @@ describe('ReactDOMForm', () => {
15011501
]);
15021502
assertLog([
15031503
'Suspend! [Count: 1]',
1504-
1505-
...(gate('enableSiblingPrerendering') ? ['Suspend! [Count: 1]'] : []),
1504+
// pre-warming
1505+
'Suspend! [Count: 1]',
15061506
]);
15071507
expect(container.textContent).toBe('Count: 0');
15081508
});

packages/react-dom/src/__tests__/ReactDOMSuspensePlaceholder-test.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,10 @@ describe('ReactDOMSuspensePlaceholder', () => {
164164
'A',
165165
'Suspend! [B]',
166166
'Loading...',
167-
168-
...(gate('enableSiblingPrerendering') ? ['A', 'Suspend! [B]', 'C'] : []),
167+
// pre-warming
168+
'A',
169+
'Suspend! [B]',
170+
'C',
169171
]);
170172
await act(() => {
171173
resolveText('B');

packages/react-dom/src/__tests__/ReactWrongReturnPointer-test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,8 @@ test('regression (#20932): return pointer is correct before entering deleted tre
196196
'Suspend! [0]',
197197
'Loading Async...',
198198
'Loading Tail...',
199-
200-
...(gate('enableSiblingPrerendering') ? ['Suspend! [0]'] : []),
199+
// pre-warming
200+
'Suspend! [0]',
201201
]);
202202
await act(() => {
203203
resolveText(0);
@@ -211,7 +211,7 @@ test('regression (#20932): return pointer is correct before entering deleted tre
211211
'Loading Async...',
212212
'Suspend! [1]',
213213
'Loading Async...',
214-
215-
...(gate('enableSiblingPrerendering') ? ['Suspend! [1]'] : []),
214+
// pre-warming
215+
'Suspend! [1]',
216216
]);
217217
});

packages/react-reconciler/src/ReactFiberCompleteWork.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ import {
4141
enableRenderableContext,
4242
passChildrenWhenCloningPersistedNodes,
4343
disableLegacyMode,
44-
enableSiblingPrerendering,
4544
enableViewTransition,
4645
enableSuspenseyImages,
4746
} from 'shared/ReactFeatureFlags';
@@ -667,9 +666,7 @@ function scheduleRetryEffect(
667666

668667
// Track the lanes that have been scheduled for an immediate retry so that
669668
// we can mark them as suspended upon committing the root.
670-
if (enableSiblingPrerendering) {
671-
markSpawnedRetryLane(retryLane);
672-
}
669+
markSpawnedRetryLane(retryLane);
673670
}
674671
}
675672

0 commit comments

Comments
 (0)