@@ -33,6 +33,7 @@ import {
33
33
enableSchedulingProfiler ,
34
34
enableScopeAPI ,
35
35
enableDoubleInvokingEffects ,
36
+ disableSchedulerTimeoutInWorkLoop ,
36
37
} from 'shared/ReactFeatureFlags' ;
37
38
import ReactSharedInternals from 'shared/ReactSharedInternals' ;
38
39
import invariant from 'shared/invariant' ;
@@ -775,7 +776,7 @@ function ensureRootIsScheduled(root: FiberRoot, currentTime: number) {
775
776
776
777
// This is the entry point for every concurrent task, i.e. anything that
777
778
// goes through Scheduler.
778
- function performConcurrentWorkOnRoot ( root ) {
779
+ function performConcurrentWorkOnRoot ( root , didTimeout ) {
779
780
if ( enableProfilerTimer && enableProfilerNestedUpdatePhase ) {
780
781
resetNestedUpdateFlag ( ) ;
781
782
}
@@ -819,6 +820,18 @@ function performConcurrentWorkOnRoot(root) {
819
820
return null ;
820
821
}
821
822
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
+
822
835
let exitStatus = renderRootConcurrent ( root , lanes ) ;
823
836
824
837
if (
0 commit comments