8000 Clean up enableSiblingPrerendering flag by jackpope · Pull Request #32319 · facebook/react · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Clean up enableSiblingPrerendering flag #32319

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 35 additions & 25 deletions packages/react-cache/src/__tests__/ReactCacheOld-test.internal.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ describe('ReactCache', () => {
await waitForAll([
'Suspend! [Hi]',
'Loading...',

...(gate('enableSiblingPrerendering') ? ['Suspend! [Hi]'] : []),
// pre-warming
'Suspend! [Hi]',
]);

jest.advanceTimersByTime(100);
Expand All @@ -150,8 +150,8 @@ describe('ReactCache', () => {
await waitForAll([
'Suspend! [Hi]',
'Loading...',

...(gate('enableSiblingPrerendering') ? ['Suspend! [Hi]'] : []),
// pre-warming
'Suspend! [Hi]',
]);

textResourceShouldFail = true;
Expand Down Expand Up @@ -195,36 +195,33 @@ describe('ReactCache', () => {
await waitForAll([
'App',
'Loading...',

...(gate('enableSiblingPrerendering') ? ['App'] : []),
// pre-warming
'App',
]);
assertConsoleErrorDev([
'Invalid key type. Expected a string, number, symbol, or ' +
"boolean, but instead received: [ 'Hi', 100 ]\n\n" +
'To use non-primitive values as keys, you must pass a hash ' +
'function as the second argument to createResource().\n' +
' in App (at **)',
...(gate('enableSiblingPrerendering')
? [
'Invalid key type. Expected a string, number, symbol, or ' +
"boolean, but instead received: [ 'Hi', 100 ]\n\n" +
'To use non-primitive values as keys, you must pass a hash ' +
'function as the second argument to createResource().\n' +
' in App (at **)',
]
: []),

// pre-warming
'Invalid key type. Expected a string, number, symbol, or ' +
"boolean, but instead received: [ 'Hi', 100 ]\n\n" +
'To use non-primitive values as keys, you must pass a hash ' +
'function as the second argument to createResource().\n' +
' in App (at **)',
]);
} else {
await waitForAll([
'App',
'Loading...',

...(gate('enableSiblingPrerendering') ? ['App'] : []),
// pre-warming
'App',
]);
}
});

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

Expand All @@ -240,15 +237,28 @@ describe('ReactCache', () => {
await waitForPaint(['Suspend! [1]', 'Loading...']);
jest.advanceTimersByTime(100);
assertLog(['Promise resolved [1]']);
await waitForAll([1, 'Suspend! [2]']);
await waitForAll([
1,
'Suspend! [2]',
...(gate('alwaysThrottleRetries')
? []
: [1, 'Suspend! [2]', 'Suspend! [3]']),
]);

jest.advanceTimersByTime(100);
assertLog(['Promise resolved [2]']);
await waitForAll([1, 2, 'Suspend! [3]']);
assertLog([
'Promise resolved [2]',
...(gate('alwaysThrottleRetries') ? [] : ['Promise resolved [3]']),
]);
await waitForAll([
1,
2,
...(gate('alwaysThrottleRetries') ? ['Suspend! [3]'] : [3]),
]);

jest.advanceTimersByTime(100);
assertLog(['Promise resolved [3]']);
await waitForAll([1, 2, 3]);
assertLog(gate('alwaysThrottleRetries') ? ['Promise resolved [3]'] : []);
await waitForAll(gate('alwaysThrottleRetries') ? [1, 2, 3] : []);

await act(() => jest.advanceTimersByTime(100));
expect(root).toMatchRenderedOutput('123');
Expand Down Expand Up @@ -378,8 +388,8 @@ describe('ReactCache', () => {
await waitForAll([
'Suspend! [Hi]',
'Loading...',

...(gate('enableSiblingPrerendering') ? ['Suspend! [Hi]'] : []),
// pre-warming
'Suspend! [Hi]',
]);

resolveThenable('Hi');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,11 @@ import {
normalizeCodeLocInfo,
} from './utils';

import {ReactVersion} from '../../../../ReactVersions';
import semver from 'semver';

let React = require('react');
let Scheduler;
let store;
let utils;

// TODO: This is how other DevTools tests access the version but we should find
// a better solution for this
const ReactVersionTestingAgainst = process.env.REACT_VERSION || ReactVersion;
// Disabling this while the flag is off in experimental. Leaving the logic so we can
// restore the behavior when we turn the flag back on.
const enableSiblingPrerendering =
false && semver.gte(ReactVersionTestingAgainst, '19.0.0');

// This flag is on experimental which disables timeline profiler.
const enableComponentPerformanceTrack =
React.version.startsWith('19') && React.version.includes('experimental');
Expand Down Expand Up @@ -1678,8 +1667,8 @@ describe('Timeline profiler', () => {

await waitForAll([
'suspended',

...(enableSiblingPrerendering ? ['suspended'] : []),
// pre-warming
'suspended',
]);

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

// Verify the Suspense event and duration was recorded.
if (enableSiblingPrerendering) {
expect(timelineData.suspenseEvents).toMatchInlineSnapshot(`
expect(timelineData.suspenseEvents).toMatchInlineSnapshot(`
[
{
"componentName": "Example",
Expand Down Expand Up @@ -1720,29 +1708,11 @@ describe('Timeline profiler', () => {
},
]
`);
} else {
const suspenseEvent = timelineData.suspenseEvents[0];
expect(suspenseEvent).toMatchInlineSnapshot(`
{
"componentName": "Example",
"depth": 0,
"duration": 10,
"id": "0",
"phase": "mount",
"promiseName": "",
"resolution": "resolved",
"timestamp": 10,
"type": "suspense",
"warning": null,
}
`);
}

// There should be two batches of renders: Suspeneded and resolved.
expect(timelineData.batchUIDToMeasuresMap.size).toBe(2);
expect(timelineData.componentMeasures).toHaveLength(
enableSiblingPrerendering ? 3 : 2,
);
// An additional measure with pre-warming
expect(timelineData.componentMeasures).toHaveLength(3);
});

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

await waitForAll([
'suspended',

...(enableSiblingPrerendering ? ['suspended'] : []),
]);
await waitForAll(['suspended', 'suspended']);

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

// Verify the Suspense event and duration was recorded.
if (enableSiblingPrerendering) {
expect(timelineData.suspenseEvents).toMatchInlineSnapshot(`
expect(timelineData.suspenseEvents).toMatchInlineSnapshot(`
[
{
"componentName": "Example",
Expand Down Expand Up @@ -1813,30 +1778,11 @@ describe('Timeline profiler', () => {
},
]
`);
} else {
expect(timelineData.suspenseEvents).toHaveLength(1);
const suspenseEvent = timelineData.suspenseEvents[0];
expect(suspenseEvent).toMatchInlineSnapshot(`
{
"componentName": "Example",
"depth": 0,
"duration": 10,
"id": "0",
"phase": "mount",
"promiseName": "",
"resolution": "rejected",
"timestamp": 10,
"type": "suspense",
"warning": null,
}
`);
}

// There should be two batches of renders: Suspeneded and resolved.
expect(timelineData.batchUIDToMeasuresMap.size).toBe(2);
expect(timelineData.componentMeasures).toHaveLength(
enableSiblingPrerendering ? 3 : 2,
);
// An additional measure with pre-warming
expect(timelineData.componentMeasures).toHaveLength(3);
});

it('should mark cascading class component state updates', async () => {
Expand Down
3 changes: 2 additions & 1 deletion packages/react-dom/src/__tests__/ReactDOMFiberAsync-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,8 @@ describe('ReactDOMFiberAsync', () => {
// Because it suspended, it remains on the current path
expect(div.textContent).toBe('/path/a');
});
assertLog(gate('enableSiblingPrerendering') ? ['Suspend! [/path/b]'] : []);
// pre-warming
assertLog(['Suspend! [/path/b]']);

await act(async () => {
resolvePromise();
Expand Down
16 changes: 8 additions & 8 deletions packages/react-dom/src/__tests__/ReactDOMForm-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1437,8 +1437,8 @@ describe('ReactDOMForm', () => {
assertLog([
'Suspend! [Count: 0]',
'Loading...',

...(gate('enableSiblingPrerendering') ? ['Suspend! [Count: 0]'] : []),
// pre-warming
'Suspend! [Count: 0]',
]);
await act(() => resolveText('Count: 0'));
assertLog(['Count: 0']);
Expand All @@ -1448,8 +1448,8 @@ describe('ReactDOMForm', () => {
assertLog([
'Suspend! [Count: 1]',
'Loading...',

...(gate('enableSiblingPrerendering') ? ['Suspend! [Count: 1]'] : []),
// pre-warming
'Suspend! [Count: 1]',
]);
expect(container.textContent).toBe('Loading...');

Expand Down Expand Up @@ -1482,8 +1482,8 @@ describe('ReactDOMForm', () => {
await act(() => root.render(<App />));
assertLog([
'Suspend! [Count: 0]',

...(gate('enableSiblingPrerendering') ? ['Suspend! [Count: 0]'] : []),
// pre-warming
'Suspend! [Count: 0]',
]);
await act(() => resolveText('Count: 0'));
assertLog(['Count: 0']);
Expand All @@ -1501,8 +1501,8 @@ describe('ReactDOMForm', () => {
]);
assertLog([
'Suspend! [Count: 1]',

...(gate('enableSiblingPrerendering') ? ['Suspend! [Count: 1]'] : []),
// pre-warming
'Suspend! [Count: 1]',
]);
expect(container.textContent).toBe('Count: 0');
});
Expand Down
E377
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,10 @@ describe('ReactDOMSuspensePlaceholder', () => {
'A',
'Suspend! [B]',
'Loading...',

...(gate('enableSiblingPrerendering') ? ['A', 'Suspend! [B]', 'C'] : []),
// pre-warming
'A',
'Suspend! [B]',
'C',
]);
await act(() => {
resolveText('B');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@ test('regression (#20932): return pointer is correct before entering deleted tre
'Suspend! [0]',
'Loading Async...',
'Loading Tail...',

...(gate('enableSiblingPrerendering') ? ['Suspend! [0]'] : []),
// pre-warming
'Suspend! [0]',
]);
await act(() => {
resolveText(0);
Expand All @@ -211,7 +211,7 @@ test('regression (#20932): return pointer is correct before entering deleted tre
'Loading Async...',
'Suspend! [1]',
'Loading Async...',

...(gate('enableSiblingPrerendering') ? ['Suspend! [1]'] : []),
// pre-warming
'Suspend! [1]',
]);
});
5 changes: 1 addition & 4 deletions packages/react-reconciler/src/ReactFiberCompleteWork.js
2851
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import {
enableRenderableContext,
passChildrenWhenCloningPersistedNodes,
disableLegacyMode,
enableSiblingPrerendering,
enableViewTransition,
enableSuspenseyImages,
} from 'shared/ReactFeatureFlags';
Expand Down Expand Up @@ -667,9 +666,7 @@ function scheduleRetryEffect(

// Track the lanes that have been scheduled for an immediate retry so that
// we can mark them as suspended upon committing the root.
if (enableSiblingPrerendering) {
markSpawnedRetryLane(retryLane);
}
markSpawnedRetryLane(retryLane);
}
}

Expand Down
Loading
Loading
0