File tree 2 files changed +21
-2
lines changed
packages/react-reconciler/src
2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -46,7 +46,9 @@ export const InputContinuousLane: Lane = /* */ 0b0000000000000000000
46
46
export const DefaultHydrationLane : Lane = /* */ 0b0000000000000000000000000010000 ;
47
47
export const DefaultLane : Lane = /* */ 0b0000000000000000000000000100000 ;
48
48
49
- export const SyncUpdateLanes : Lane = /* */ 0b0000000000000000000000000101010 ;
49
+ export const SyncUpdateLanes : Lane = enableUnifiedSyncLane
50
+ ? SyncLane | InputContinuousLane | DefaultLane
51
+ : SyncLane ;
50
52
51
53
const TransitionHydrationLane : Lane = /* */ 0b0000000000000000000000001000000 ;
52
54
const TransitionLanes : Lanes = /* */ 0b0000000011111111111111110000000 ;
@@ -84,6 +86,11 @@ export const IdleLane: Lane = /* */ 0b0100000000000000000
84
86
85
87
export const OffscreenLane : Lane = /* */ 0b1000000000000000000000000000000 ;
86
88
89
+ // Any lane that might schedule an update. This is used to detect infinite
90
+ // update loops, so it doesn't include hydration lanes or retries.
91
+ export const UpdateLanes : Lanes =
92
+ SyncLane | InputContinuousLane | DefaultLane | TransitionLanes ;
93
+
87
94
// This function is used for the experimental timeline (react-devtools-timeline)
88
95
// It should be kept in sync with the Lanes values above.
89
96
export function getLabelForLane ( lane : Lane ) : string | void {
Original file line number Diff line number Diff line change @@ -154,6 +154,8 @@ import {
154
154
includesOnlyNonUrgentLanes ,
155
155
includesSomeLane ,
156
156
OffscreenLane ,
157
+ SyncUpdateLanes ,
158
+ UpdateLanes ,
157
159
} from './ReactFiberLane' ;
158
160
import {
159
161
DiscreteEventPriority ,
@@ -2932,7 +2934,17 @@ function commitRootImpl(
2932
2934
2933
2935
// Read this again, since a passive effect might have updated it
2934
2936
remainingLanes = root . pendingLanes ;
2935
- if ( includesSyncLane ( remainingLanes ) ) {
2937
+
2938
+ // Check if this render scheduled a cascading synchronous update. This is a
2939
+ // heurstic to detect infinite update loops. We are intentionally excluding
2940
+ // hydration lanes in this check, because render triggered by selective
2941
+ // hydration is conceptually not an update.
2942
+ if (
2943
+ // Was the finished render the result of an update (not hydration)?
2944
+ includesSomeLane ( lanes , UpdateLanes ) &&
2945
+ // Did it schedule a sync update?
2946
+ includesSomeLane ( remainingLanes , SyncUpdateLanes )
2947
+ ) {
2936
2948
if ( enableProfilerTimer && enableProfilerNestedUpdatePhase ) {
2937
2949
markNestedUpdateScheduled ( ) ;
2938
2950
}
You can’t perform that action at this time.
0 commit comments