Skip to content

Commit

Permalink
Add alwaysThrottleRetries flag (#26685)
Browse files Browse the repository at this point in the history
This puts the change introduced by #26611 behind a flag until Meta is
able to roll it out. Disabling the flag reverts back to the old
behavior, where retries are throttled if there's still data remaining in
the tree, but not if all the data has finished loading.

The new behavior is still enabled in the public builds.

DiffTrain build for commit d73d7d5.
  • Loading branch information
acdlite committed Apr 20, 2023
1 parent ec3ec56 commit 12d760c
Show file tree
Hide file tree
Showing 13 changed files with 149 additions and 132 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<fb35677e465a0575f9b39e24b8b35767>>
* @generated SignedSource<<43355784ad4a055ab0a02e5c5e648c88>>
*/

'use strict';
Expand Down Expand Up @@ -145,7 +145,8 @@ var createRootStrictEffectsByDefault = false;
var enableLazyContextPropagation = false;
var enableLegacyHidden = false;
var diffInCommitPhase = true;
var enableAsyncActions = false; // Flow magic to verify the exports of this file match the original version.
var enableAsyncActions = false;
var alwaysThrottleRetries = true; // Flow magic to verify the exports of this file match the original version.

var FunctionComponent = 0;
var ClassComponent = 1;
Expand Down Expand Up @@ -20431,7 +20432,7 @@ function finishConcurrentRender(root, exitStatus, finishedWork, lanes) {
workInProgressTransitions
);
} else {
if (includesOnlyRetries(lanes)) {
if (includesOnlyRetries(lanes) && alwaysThrottleRetries) {
// This render only included retries, no updates. Throttle committing
// retries so that we don't show too many loading states too quickly.
var msUntilTimeout =
Expand Down Expand Up @@ -23858,7 +23859,7 @@ function createFiberRoot(
return root;
}

var ReactVersion = "18.3.0-next-7f8c501f6-20230420";
var ReactVersion = "18.3.0-next-d73d7d590-20230420";

// Might add PROFILE later.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8599,7 +8599,7 @@ var devToolsConfig$jscomp$inline_1021 = {
throw Error("TestRenderer does not support findFiberByHostInstance()");
},
bundleType: 0,
version: "18.3.0-next-7f8c501f6-20230420",
version: "18.3.0-next-d73d7d590-20230420",
rendererPackageName: "react-test-renderer"
};
var internals$jscomp$inline_1206 = {
Expand Down Expand Up @@ -8630,7 +8630,7 @@ var internals$jscomp$inline_1206 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.3.0-next-7f8c501f6-20230420"
reconcilerVersion: "18.3.0-next-d73d7d590-20230420"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1207 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9025,7 +9025,7 @@ var devToolsConfig$jscomp$inline_1063 = {
throw Error("TestRenderer does not support findFiberByHostInstance()");
},
bundleType: 0,
version: "18.3.0-next-7f8c501f6-20230420",
version: "18.3.0-next-d73d7d590-20230420",
rendererPackageName: "react-test-renderer"
};
var internals$jscomp$inline_1247 = {
Expand Down Expand Up @@ -9056,7 +9056,7 @@ var internals$jscomp$inline_1247 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.3.0-next-7f8c501f6-20230420"
reconcilerVersion: "18.3.0-next-d73d7d590-20230420"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1248 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ if (
}
"use strict";

var ReactVersion = "18.3.0-next-7f8c501f6-20230420";
var ReactVersion = "18.3.0-next-d73d7d590-20230420";

// ATTENTION
// When adding new symbols to this file,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -639,4 +639,4 @@ exports.useSyncExternalStore = function (
);
};
exports.useTransition = useTransition;
exports.version = "18.3.0-next-7f8c501f6-20230420";
exports.version = "18.3.0-next-d73d7d590-20230420";
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ exports.useSyncExternalStore = function (
);
};
exports.useTransition = useTransition;
exports.version = "18.3.0-next-7f8c501f6-20230420";
exports.version = "18.3.0-next-d73d7d590-20230420";

/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
if (
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7f8c501f682bd4abe24826a93538059d717ba39e
d73d7d59086218b0fa42d0a79c32a0365952650b
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<13be0ed73b0dd62cc37d1e24af8fe51a>>
* @generated SignedSource<<78a825a4d424f226b6f344ef3a16b2ec>>
*/

'use strict';
Expand Down Expand Up @@ -3198,7 +3198,8 @@ function dispatchEvent(target, topLevelType, nativeEvent) {

var enableUseRefAccessWarning = dynamicFlags.enableUseRefAccessWarning,
enableDeferRootSchedulingToMicrotask =
dynamicFlags.enableDeferRootSchedulingToMicrotask; // The rest of the flags are static for better dead code elimination.
dynamicFlags.enableDeferRootSchedulingToMicrotask,
alwaysThrottleRetries = dynamicFlags.alwaysThrottleRetries; // The rest of the flags are static for better dead code elimination.
var enableSchedulingProfiler = true;
var enableProfilerTimer = true;
var enableProfilerCommitHooks = true;
Expand Down Expand Up @@ -23536,7 +23537,10 @@ function finishConcurrentRender(root, exitStatus, finishedWork, lanes) {
workInProgressTransitions
);
} else {
if (includesOnlyRetries(lanes)) {
if (
includesOnlyRetries(lanes) &&
(alwaysThrottleRetries || exitStatus === RootSuspended)
) {
// This render only included retries, no updates. Throttle committing
// retries so that we don't show too many loading states too quickly.
var msUntilTimeout =
Expand Down Expand Up @@ -27165,7 +27169,7 @@ function createFiberRoot(
return root;
}

var ReactVersion = "18.3.0-next-7f8c501f6-20230420";
var ReactVersion = "18.3.0-next-d73d7d590-20230420";

function createPortal$1(
children,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<0b0bda830df48380bcde0d6ac5c73756>>
* @generated SignedSource<<472cb7f28d742af2e290a0816a880f33>>
*/

"use strict";
Expand Down Expand Up @@ -1317,6 +1317,7 @@ function dispatchEvent(target, topLevelType, nativeEvent) {
var enableUseRefAccessWarning = dynamicFlags.enableUseRefAccessWarning,
enableDeferRootSchedulingToMicrotask =
dynamicFlags.enableDeferRootSchedulingToMicrotask,
alwaysThrottleRetries = dynamicFlags.alwaysThrottleRetries,
scheduleCallback$2 = Scheduler.unstable_scheduleCallback,
cancelCallback$1 = Scheduler.unstable_cancelCallback,
shouldYield = Scheduler.unstable_shouldYield,
Expand Down Expand Up @@ -7567,59 +7568,59 @@ function performConcurrentWorkOnRoot(root, didTimeout) {
root === workInProgressRoot ? workInProgressRootRenderLanes : 0
);
if (0 === lanes) return null;
didTimeout =
var exitStatus =
includesBlockingLane(root, lanes) ||
0 !== (lanes & root.expiredLanes) ||
didTimeout
? renderRootSync(root, lanes)
: renderRootConcurrent(root, lanes);
if (0 !== didTimeout) {
if (2 === didTimeout) {
var originallyAttemptedLanes = lanes,
errorRetryLanes = getLanesToRetrySynchronouslyOnError(
root,
originallyAttemptedLanes
);
if (0 !== exitStatus) {
if (2 === exitStatus) {
didTimeout = lanes;
var errorRetryLanes = getLanesToRetrySynchronouslyOnError(
root,
didTimeout
);
0 !== errorRetryLanes &&
((lanes = errorRetryLanes),
(didTimeout = recoverFromConcurrentError(
(exitStatus = recoverFromConcurrentError(
root,
originallyAttemptedLanes,
didTimeout,
errorRetryLanes
)));
}
if (1 === didTimeout)
if (1 === exitStatus)
throw (
((originalCallbackNode = workInProgressRootFatalError),
prepareFreshStack(root, 0),
markRootSuspended(root, lanes),
ensureRootIsScheduled(root),
originalCallbackNode)
);
if (6 === didTimeout) markRootSuspended(root, lanes);
if (6 === exitStatus) markRootSuspended(root, lanes);
else {
errorRetryLanes = !includesBlockingLane(root, lanes);
originallyAttemptedLanes = root.current.alternate;
didTimeout = root.current.alternate;
if (
errorRetryLanes &&
!isRenderConsistentWithExternalStores(originallyAttemptedLanes)
!isRenderConsistentWithExternalStores(didTimeout)
) {
didTimeout = renderRootSync(root, lanes);
if (2 === didTimeout) {
exitStatus = renderRootSync(root, lanes);
if (2 === exitStatus) {
errorRetryLanes = lanes;
var errorRetryLanes$96 = getLanesToRetrySynchronouslyOnError(
root,
errorRetryLanes
);
0 !== errorRetryLanes$96 &&
((lanes = errorRetryLanes$96),
(didTimeout = recoverFromConcurrentError(
(exitStatus = recoverFromConcurrentError(
root,
errorRetryLanes,
errorRetryLanes$96
)));
}
if (1 === didTimeout)
if (1 === exitStatus)
throw (
((originalCallbackNode = workInProgressRootFatalError),
prepareFreshStack(root, 0),
Expand All @@ -7628,10 +7629,10 @@ function performConcurrentWorkOnRoot(root, didTimeout) {
originalCallbackNode)
);
}
root.finishedWork = originallyAttemptedLanes;
root.finishedWork = didTimeout;
root.finishedLanes = lanes;
a: {
switch (didTimeout) {
switch (exitStatus) {
case 0:
case 1:
throw Error("Root did not complete. This is a bug in React.");
Expand All @@ -7650,27 +7651,28 @@ function performConcurrentWorkOnRoot(root, didTimeout) {
}
if (
(lanes & 125829120) === lanes &&
((didTimeout = globalMostRecentFallbackTime + 500 - now()),
10 < didTimeout)
(alwaysThrottleRetries || 3 === exitStatus) &&
((exitStatus = globalMostRecentFallbackTime + 500 - now()),
10 < exitStatus)
) {
markRootSuspended(root, lanes);
if (0 !== getNextLanes(root, 0)) break a;
root.timeoutHandle = scheduleTimeout(
commitRootWhenReady.bind(
null,
root,
originallyAttemptedLanes,
didTimeout,
workInProgressRootRecoverableErrors,
workInProgressTransitions,
lanes
),
didTimeout
exitStatus
);
break a;
}
commitRootWhenReady(
root,
originallyAttemptedLanes,
didTimeout,
workInProgressRootRecoverableErrors,
workInProgressTransitions,
lanes
Expand Down Expand Up @@ -9468,7 +9470,7 @@ var roots = new Map(),
devToolsConfig$jscomp$inline_1045 = {
findFiberByHostInstance: getInstanceFromNode,
bundleType: 0,
version: "18.3.0-next-7f8c501f6-20230420",
version: "18.3.0-next-d73d7d590-20230420",
rendererPackageName: "react-native-renderer",
rendererConfig: {
getInspectorDataForViewTag: function () {
Expand Down Expand Up @@ -9510,7 +9512,7 @@ var internals$jscomp$inline_1276 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.3.0-next-7f8c501f6-20230420"
reconcilerVersion: "18.3.0-next-d73d7d590-20230420"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1277 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down
Loading

0 comments on commit 12d760c

Please sign in to comment.