From 3eba6521140b271453794eb6105e9ca8a6fa5e0c Mon Sep 17 00:00:00 2001 From: Jan Kassens Date: Tue, 14 Nov 2023 10:15:17 -0500 Subject: [PATCH] Add a feature flag to enable expiration of retry lanes (#27694) An attempt to see if we can bring back expiration of retry lanes to avoid cases resolving Suspense can be starved by frequent updates. In the past, this caused increase browser crashes, but a lot of time has passed since then. Just trying if we can re-enable this. Old PR that reverted adding the timeout: https://github.com/facebook/react/pull/21300 --- packages/react-reconciler/src/ReactFiberLane.js | 7 ++++--- packages/shared/ReactFeatureFlags.js | 5 +++++ packages/shared/forks/ReactFeatureFlags.native-fb.js | 1 + packages/shared/forks/ReactFeatureFlags.native-oss.js | 1 + packages/shared/forks/ReactFeatureFlags.test-renderer.js | 1 + .../shared/forks/ReactFeatureFlags.test-renderer.native.js | 1 + .../shared/forks/ReactFeatureFlags.test-renderer.www.js | 1 + packages/shared/forks/ReactFeatureFlags.www-dynamic.js | 1 + packages/shared/forks/ReactFeatureFlags.www.js | 1 + 9 files changed, 16 insertions(+), 3 deletions(-) diff --git a/packages/react-reconciler/src/ReactFiberLane.js b/packages/react-reconciler/src/ReactFiberLane.js index 75bf09dc01e25..905eda36a93e8 100644 --- a/packages/react-reconciler/src/ReactFiberLane.js +++ b/packages/react-reconciler/src/ReactFiberLane.js @@ -19,11 +19,12 @@ export type Lane = number; export type LaneMap = Array; import { - enableSchedulingProfiler, - enableUpdaterTracking, allowConcurrentByDefault, + enableRetryLaneExpiration, + enableSchedulingProfiler, enableTransitionTracing, enableUnifiedSyncLane, + enableUpdaterTracking, } from 'shared/ReactFeatureFlags'; import {isDevToolsPresent} from './ReactFiberDevToolsHook'; import {ConcurrentUpdatesByDefaultMode, NoMode} from './ReactTypeOfMode'; @@ -383,7 +384,7 @@ function computeExpirationTime(lane: Lane, currentTime: number) { // crashes. There must be some other underlying bug; not super urgent but // ideally should figure out why and fix it. Unfortunately we don't have // a repro for the crashes, only detected via production metrics. - return NoTimestamp; + return enableRetryLaneExpiration ? currentTime + 5000 : NoTimestamp; case SelectiveHydrationLane: case IdleHydrationLane: case IdleLane: diff --git a/packages/shared/ReactFeatureFlags.js b/packages/shared/ReactFeatureFlags.js index 0a532cf9296a5..7411bc7d9a92c 100644 --- a/packages/shared/ReactFeatureFlags.js +++ b/packages/shared/ReactFeatureFlags.js @@ -128,6 +128,11 @@ export const passChildrenWhenCloningPersistedNodes = false; export const enableUseDeferredValueInitialArg = __EXPERIMENTAL__; +/** + * Enables an expiration time for retry lanes to avoid starvation. + */ +export const enableRetryLaneExpiration = false; + // ----------------------------------------------------------------------------- // Chopping Block // diff --git a/packages/shared/forks/ReactFeatureFlags.native-fb.js b/packages/shared/forks/ReactFeatureFlags.native-fb.js index 9645e0fc953a4..0c04991e13b7d 100644 --- a/packages/shared/forks/ReactFeatureFlags.native-fb.js +++ b/packages/shared/forks/ReactFeatureFlags.native-fb.js @@ -66,6 +66,7 @@ export const enableComponentStackLocations = false; export const enableLegacyFBSupport = false; export const enableFilterEmptyStringAttributesDOM = false; export const enableGetInspectorDataForInstanceInProduction = true; +export const enableRetryLaneExpiration = false; export const createRootStrictEffectsByDefault = false; diff --git a/packages/shared/forks/ReactFeatureFlags.native-oss.js b/packages/shared/forks/ReactFeatureFlags.native-oss.js index eea399034b248..70105f99ce48e 100644 --- a/packages/shared/forks/ReactFeatureFlags.native-oss.js +++ b/packages/shared/forks/ReactFeatureFlags.native-oss.js @@ -49,6 +49,7 @@ export const enableComponentStackLocations = false; export const enableLegacyFBSupport = false; export const enableFilterEmptyStringAttributesDOM = false; export const enableGetInspectorDataForInstanceInProduction = false; +export const enableRetryLaneExpiration = false; export const createRootStrictEffectsByDefault = false; export const enableUseRefAccessWarning = false; diff --git a/packages/shared/forks/ReactFeatureFlags.test-renderer.js b/packages/shared/forks/ReactFeatureFlags.test-renderer.js index 33db09795b26c..1f1766c61789a 100644 --- a/packages/shared/forks/ReactFeatureFlags.test-renderer.js +++ b/packages/shared/forks/ReactFeatureFlags.test-renderer.js @@ -49,6 +49,7 @@ export const enableComponentStackLocations = true; export const enableLegacyFBSupport = false; export const enableFilterEmptyStringAttributesDOM = false; export const enableGetInspectorDataForInstanceInProduction = false; +export const enableRetryLaneExpiration = false; export const createRootStrictEffectsByDefault = false; export const enableUseRefAccessWarning = false; diff --git a/packages/shared/forks/ReactFeatureFlags.test-renderer.native.js b/packages/shared/forks/ReactFeatureFlags.test-renderer.native.js index 96f7a0f831024..18fa67530ad5d 100644 --- a/packages/shared/forks/ReactFeatureFlags.test-renderer.native.js +++ b/packages/shared/forks/ReactFeatureFlags.test-renderer.native.js @@ -51,6 +51,7 @@ export const enableUseEffectEventHook = false; export const enableClientRenderFallbackOnTextMismatch = true; export const createRootStrictEffectsByDefault = false; export const enableUseRefAccessWarning = false; +export const enableRetryLaneExpiration = false; export const disableSchedulerTimeoutInWorkLoop = false; export const enableLazyContextPropagation = false; diff --git a/packages/shared/forks/ReactFeatureFlags.test-renderer.www.js b/packages/shared/forks/ReactFeatureFlags.test-renderer.www.js index 0b3301bc39e8d..c4131e3312c54 100644 --- a/packages/shared/forks/ReactFeatureFlags.test-renderer.www.js +++ b/packages/shared/forks/ReactFeatureFlags.test-renderer.www.js @@ -49,6 +49,7 @@ export const enableComponentStackLocations = true; export const enableLegacyFBSupport = false; export const enableFilterEmptyStringAttributesDOM = true; export const enableGetInspectorDataForInstanceInProduction = false; +export const enableRetryLaneExpiration = false; export const createRootStrictEffectsByDefault = false; export const enableUseRefAccessWarning = false; diff --git a/packages/shared/forks/ReactFeatureFlags.www-dynamic.js b/packages/shared/forks/ReactFeatureFlags.www-dynamic.js index 1fb76bf4b31de..b824c9ac8323c 100644 --- a/packages/shared/forks/ReactFeatureFlags.www-dynamic.js +++ b/packages/shared/forks/ReactFeatureFlags.www-dynamic.js @@ -29,6 +29,7 @@ export const enableAsyncActions = __VARIANT__; export const alwaysThrottleRetries = __VARIANT__; export const enableDO_NOT_USE_disableStrictPassiveEffect = __VARIANT__; export const enableUseDeferredValueInitialArg = __VARIANT__; +export const enableRetryLaneExpiration = __VARIANT__; // Enable this flag to help with concurrent mode debugging. // It logs information to the console about React scheduling, rendering, and commit phases. diff --git a/packages/shared/forks/ReactFeatureFlags.www.js b/packages/shared/forks/ReactFeatureFlags.www.js index d53742c5f5c08..a597b8e98058c 100644 --- a/packages/shared/forks/ReactFeatureFlags.www.js +++ b/packages/shared/forks/ReactFeatureFlags.www.js @@ -24,6 +24,7 @@ export const { enableUseRefAccessWarning, enableLazyContextPropagation, enableUnifiedSyncLane, + enableRetryLaneExpiration, enableTransitionTracing, enableCustomElementPropertySupport, enableDeferRootSchedulingToMicrotask,