Skip to content

Commit 5687864

Browse files
authored
Add back disableSchedulerTimeoutInWorkLoop flag (#20482)
* Add back enableSchedulerTimeoutInWorkLoop flag * Nvm, keep it as disableSchedulerTimeoutInWorkLoop
1 parent 9f338e5 commit 5687864

12 files changed

+39
-2
lines changed

packages/react-reconciler/src/ReactFiberWorkLoop.new.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import {
3131
enableDebugTracing,
3232
enableSchedulingProfiler,
3333
enableScopeAPI,
34+
disableSchedulerTimeoutInWorkLoop,
3435
} from 'shared/ReactFeatureFlags';
3536
import ReactSharedInternals from 'shared/ReactSharedInternals';
3637
import invariant from 'shared/invariant';
@@ -767,7 +768,7 @@ function ensureRootIsScheduled(root: FiberRoot, currentTime: number) {
767768

768769
// This is the entry point for every concurrent task, i.e. anything that
769770
// goes through Scheduler.
770-
function performConcurrentWorkOnRoot(root) {
771+
function performConcurrentWorkOnRoot(root, didTimeout) {
771772
if (enableProfilerTimer && enableProfilerNestedUpdatePhase) {
772773
resetNestedUpdateFlag();
773774
}
@@ -811,6 +812,18 @@ function performConcurrentWorkOnRoot(root) {
811812
return null;
812813
}
813814

815+
// TODO: We only check `didTimeout` defensively, to account for a Scheduler
816+
// bug we're still investigating. Once the bug in Scheduler is fixed,
817+
// we can remove this, since we track expiration ourselves.
818+
if (!disableSchedulerTimeoutInWorkLoop && didTimeout) {
819+
// Something expired. Flush synchronously until there's no expired
820+
// work left.
821+
markRootExpired(root, lanes);
822+
// This will schedule a synchronous callback.
823+
ensureRootIsScheduled(root, now());
824+
return null;
825+
}
826+
814827
let exitStatus = renderRootConcurrent(root, lanes);
815828

816829
if (

packages/react-reconciler/src/ReactFiberWorkLoop.old.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import {
3333
enableSchedulingProfiler,
3434
enableScopeAPI,
3535
enableDoubleInvokingEffects,
36+
disableSchedulerTimeoutInWorkLoop,
3637
} from 'shared/ReactFeatureFlags';
3738
import ReactSharedInternals from 'shared/ReactSharedInternals';
3839
import invariant from 'shared/invariant';
@@ -775,7 +776,7 @@ function ensureRootIsScheduled(root: FiberRoot, currentTime: number) {
775776

776777
// This is the entry point for every concurrent task, i.e. anything that
777778
// goes through Scheduler.
778-
function performConcurrentWorkOnRoot(root) {
779+
function performConcurrentWorkOnRoot(root, didTimeout) {
779780
if (enableProfilerTimer && enableProfilerNestedUpdatePhase) {
780781
resetNestedUpdateFlag();
781782
}
@@ -819,6 +820,18 @@ function performConcurrentWorkOnRoot(root) {
819820
return null;
820821
}
821822

823+
// TODO: We only check `didTimeout` defensively, to account for a Scheduler
824+
// bug we're still investigating. Once the bug in Scheduler is fixed,
825+
// we can remove this, since we track expiration ourselves.
826+
if (!disableSchedulerTimeoutInWorkLoop && didTimeout) {
827+
// Something expired. Flush synchronously until there's no expired
828+
// work left.
829+
markRootExpired(root, lanes);
830+
// This will schedule a synchronous callback.
831+
ensureRootIsScheduled(root, now());
832+
return null;
833+
}
834+
822835
let exitStatus = renderRootConcurrent(root, lanes);
823836

824837
if (

packages/shared/ReactFeatureFlags.js

+2
Original file line numberDiff line numberDiff line change
@@ -141,3 +141,5 @@ export const enableDoubleInvokingEffects = false;
141141
export const enableUseRefAccessWarning = false;
142142

143143
export const enableRecursiveCommitTraversal = false;
144+
145+
export const disableSchedulerTimeoutInWorkLoop = false;

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

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export const enableDoubleInvokingEffects = false;
5656
export const enableUseRefAccessWarning = false;
5757

5858
export const enableRecursiveCommitTraversal = false;
59+
export const disableSchedulerTimeoutInWorkLoop = false;
5960

6061
// Flow magic to verify the exports of this file match the original version.
6162
// eslint-disable-next-line no-unused-vars

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

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export const enableDoubleInvokingEffects = false;
5555
export const enableUseRefAccessWarning = false;
5656

5757
export const enableRecursiveCommitTraversal = false;
58+
export const disableSchedulerTimeoutInWorkLoop = false;
5859

5960
// Flow magic to verify the exports of this file match the original version.
6061
// eslint-disable-next-line no-unused-vars

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

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export const enableDoubleInvokingEffects = false;
5555
export const enableUseRefAccessWarning = false;
5656

5757
export const enableRecursiveCommitTraversal = false;
58+
export const disableSchedulerTimeoutInWorkLoop = false;
5859

5960
// Flow magic to verify the exports of this file match the original version.
6061
// eslint-disable-next-line no-unused-vars

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

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export const enableDoubleInvokingEffects = false;
5555
export const enableUseRefAccessWarning = false;
5656

5757
export const enableRecursiveCommitTraversal = false;
58+
export const disableSchedulerTimeoutInWorkLoop = false;
5859

5960
// Flow magic to verify the exports of this file match the original version.
6061
// eslint-disable-next-line no-unused-vars

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

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export const enableDoubleInvokingEffects = true;
5555
export const enableUseRefAccessWarning = false;
5656

5757
export const enableRecursiveCommitTraversal = false;
58+
export const disableSchedulerTimeoutInWorkLoop = false;
5859

5960
// Flow magic to verify the exports of this file match the original version.
6061
// eslint-disable-next-line no-unused-vars

packages/shared/forks/ReactFeatureFlags.testing.js

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export const enableDoubleInvokingEffects = false;
5555
export const enableUseRefAccessWarning = false;
5656

5757
export const enableRecursiveCommitTraversal = false;
58+
export const disableSchedulerTimeoutInWorkLoop = false;
5859

5960
// Flow magic to verify the exports of this file match the original version.
6061
// eslint-disable-next-line no-unused-vars

packages/shared/forks/ReactFeatureFlags.testing.www.js

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export const enableDoubleInvokingEffects = false;
5555
export const enableUseRefAccessWarning = false;
5656

5757
export const enableRecursiveCommitTraversal = false;
58+
export const disableSchedulerTimeoutInWorkLoop = false;
5859

5960
// Flow magic to verify the exports of this file match the original version.
6061
// eslint-disable-next-line no-unused-vars

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

+1
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,4 @@ export const enableDoubleInvokingEffects = false;
5353
export const enableUseRefAccessWarning = __VARIANT__;
5454

5555
export const enableProfilerNestedUpdateScheduledHook = __VARIANT__;
56+
export const disableSchedulerTimeoutInWorkLoop = __VARIANT__;

packages/shared/forks/ReactFeatureFlags.www.js

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export const {
2929
enableDoubleInvokingEffects,
3030
enableUseRefAccessWarning,
3131
disableNativeComponentFrames,
32+
disableSchedulerTimeoutInWorkLoop,
3233
} = dynamicFeatureFlags;
3334

3435
// On WWW, __EXPERIMENTAL__ is used for a new modern build.

0 commit comments

Comments
 (0)