Skip to content

Commit 5bef02e

Browse files
committed
Revert "Remove revertRemovalOfSiblingPrerendering killswitch (#26549)"
This reverts commit 7b0642b.
1 parent 37d901e commit 5bef02e

9 files changed

+57
-10
lines changed

packages/react-reconciler/src/ReactFiberWorkLoop.js

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import {
3838
enableCache,
3939
enableTransitionTracing,
4040
useModernStrictMode,
41+
revertRemovalOfSiblingPrerendering,
4142
disableLegacyContext,
4243
alwaysThrottleRetries,
4344
} from 'shared/ReactFeatureFlags';
@@ -2544,14 +2545,28 @@ function completeUnitOfWork(unitOfWork: Fiber): void {
25442545
// sibling. If there are no more siblings, return to the parent fiber.
25452546
let completedWork: Fiber = unitOfWork;
25462547
do {
2547-
if (__DEV__) {
2548+
if (revertRemovalOfSiblingPrerendering) {
25482549
if ((completedWork.flags & Incomplete) !== NoFlags) {
2549-
// NOTE: If we re-enable sibling prerendering in some cases, this branch
2550-
// is where we would switch to the unwinding path.
2551-
console.error(
2552-
'Internal React error: Expected this fiber to be complete, but ' +
2553-
"it isn't. It should have been unwound. This is a bug in React.",
2554-
);
2550+
// This fiber did not complete, because one of its children did not
2551+
// complete. Switch to unwinding the stack instead of completing it.
2552+
//
2553+
// The reason "unwind" and "complete" is interleaved is because when
2554+
// something suspends, we continue rendering the siblings even though
2555+
// they will be replaced by a fallback.
2556+
// TODO: Disable sibling prerendering, then remove this branch.
2557+
unwindUnitOfWork(completedWork);
2558+
return;
2559+
}
2560+
} else {
2561+
if (__DEV__) {
2562+
if ((completedWork.flags & Incomplete) !== NoFlags) {
2563+
// NOTE: If we re-enable sibling prerendering in some cases, this branch
2564+
// is where we would switch to the unwinding path.
2565+
console.error(
2566+
'Internal React error: Expected this fiber to be complete, but ' +
2567+
"it isn't. It should have been unwound. This is a bug in React.",
2568+
);
2569+
}
25552570
}
25562571
}
25572572

@@ -2655,9 +2670,24 @@ function unwindUnitOfWork(unitOfWork: Fiber): void {
26552670
returnFiber.deletions = null;
26562671
}
26572672

2658-
// NOTE: If we re-enable sibling prerendering in some cases, here we
2659-
// would switch to the normal completion path: check if a sibling
2660-
// exists, and if so, begin work on it.
2673+
if (revertRemovalOfSiblingPrerendering) {
2674+
// If there are siblings, work on them now even though they're going to be
2675+
// replaced by a fallback. We're "prerendering" them. Historically our
2676+
// rationale for this behavior has been to initiate any lazy data requests
2677+
// in the siblings, and also to warm up the CPU cache.
2678+
// TODO: Don't prerender siblings. With `use`, we suspend the work loop
2679+
// until the data has resolved, anyway.
2680+
const siblingFiber = incompleteWork.sibling;
2681+
if (siblingFiber !== null) {
2682+
// This branch will return us to the normal work loop.
2683+
workInProgress = siblingFiber;
2684+
return;
2685+
}
2686+
} else {
2687+
// NOTE: If we re-enable sibling prerendering in some cases, this branch
2688+
// is where we would switch to the normal completion path: check if a
2689+
// sibling exists, and if so, begin work on it.
2690+
}
26612691

26622692
// Otherwise, return to the parent
26632693
// $FlowFixMe[incompatible-type] we bail out when we get a null

packages/shared/ReactFeatureFlags.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ export const enableComponentStackLocations = true;
2222
// when it rolls out to prod. We should remove these as soon as possible.
2323
// -----------------------------------------------------------------------------
2424

25+
// This is phrased as a negative so that if someone forgets to add a GK, the
26+
// default is to enable the feature. It should only be overridden if there's
27+
// a regression in prod.
28+
export const revertRemovalOfSiblingPrerendering = false;
29+
2530
// -----------------------------------------------------------------------------
2631
// Land or remove (moderate effort)
2732
//

packages/shared/forks/ReactFeatureFlags.native-fb.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export const enableScopeAPI = false;
5454
export const enableCreateEventHandleAPI = false;
5555
export const enableSuspenseCallback = false;
5656
export const disableLegacyContext = false;
57+
export const revertRemovalOfSiblingPrerendering = false;
5758
export const enableTrustedTypesIntegration = false;
5859
export const disableTextareaChildren = false;
5960
export const enableSuspenseAvoidThisFallback = false;

packages/shared/forks/ReactFeatureFlags.native-oss.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export const enableScopeAPI = false;
3636
export const enableCreateEventHandleAPI = false;
3737
export const enableSuspenseCallback = false;
3838
export const disableLegacyContext = false;
39+
export const revertRemovalOfSiblingPrerendering = false;
3940
export const enableTrustedTypesIntegration = false;
4041
export const disableTextareaChildren = false;
4142
export const disableModulePatternComponents = false;

packages/shared/forks/ReactFeatureFlags.test-renderer.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export const enableScopeAPI = false;
3636
export const enableCreateEventHandleAPI = false;
3737
export const enableSuspenseCallback = false;
3838
export const disableLegacyContext = false;
39+
export const revertRemovalOfSiblingPrerendering = false;
3940
export const enableTrustedTypesIntegration = false;
4041
export const disableTextareaChildren = false;
4142
export const disableModulePatternComponents = false;

packages/shared/forks/ReactFeatureFlags.test-renderer.native.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export const enableScopeAPI = false;
3636
export const enableCreateEventHandleAPI = false;
3737
export const enableSuspenseCallback = false;
3838
export const disableLegacyContext = false;
39+
export const revertRemovalOfSiblingPrerendering = false;
3940
export const enableTrustedTypesIntegration = false;
4041
export const disableTextareaChildren = false;
4142
export const disableModulePatternComponents = false;

packages/shared/forks/ReactFeatureFlags.test-renderer.www.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export const enableScopeAPI = true;
3636
export const enableCreateEventHandleAPI = false;
3737
export const enableSuspenseCallback = true;
3838
export const disableLegacyContext = false;
39+
export const revertRemovalOfSiblingPrerendering = false;
3940
export const enableTrustedTypesIntegration = false;
4041
export const disableTextareaChildren = false;
4142
export const disableModulePatternComponents = true;

packages/shared/forks/ReactFeatureFlags.www-dynamic.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ export const enableSchedulingProfiler = __VARIANT__;
4747
// so we don't need to use __VARIANT__ to get extra coverage.
4848
export const replayFailedUnitOfWorkWithInvokeGuardedCallback = __DEV__;
4949

50+
// This flag only exists so it can be connected to a www GK that acts as a
51+
// killswitch. We don't run our tests against the `true` value because 1) it
52+
// affects too many tests 2) it shouldn't break anything. But it is mildly
53+
// risky, hence this extra precaution.
54+
export const revertRemovalOfSiblingPrerendering = false;
55+
5056
// TODO: These flags are hard-coded to the default values used in open source.
5157
// Update the tests so that they pass in either mode, then set these
5258
// to __VARIANT__.

packages/shared/forks/ReactFeatureFlags.www.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export const {
1818
disableInputAttributeSyncing,
1919
disableIEWorkarounds,
2020
enableTrustedTypesIntegration,
21+
revertRemovalOfSiblingPrerendering,
2122
replayFailedUnitOfWorkWithInvokeGuardedCallback,
2223
enableLegacyFBSupport,
2324
enableDebugTracing,

0 commit comments

Comments
 (0)