Skip to content

Commit 8d8ef64

Browse files
committed
fix: explicitly warn for infinite loops discovered only via enableInfiniteRenderLoopDetection
1 parent 80b1cab commit 8d8ef64

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

packages/react-reconciler/src/ReactFiberConcurrentUpdates.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ function getRootForUpdatedFiber(sourceFiber: Fiber): FiberRoot | null {
254254
// current behavior we've used for several release cycles. Consider not
255255
// performing this check if the updated fiber already unmounted, since it's
256256
// not possible for that to cause an infinite update loop.
257-
throwIfInfiniteUpdateLoopDetected();
257+
throwIfInfiniteUpdateLoopDetected(false);
258258

259259
// When a setState happens, we must ensure the root is scheduled. Because
260260
// update queues do not have a backpointer to the root, the only way to do

packages/react-reconciler/src/ReactFiberWorkLoop.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1754,7 +1754,7 @@ function markRootUpdated(root: FiberRoot, updatedLanes: Lanes) {
17541754
didIncludeCommitPhaseUpdate = true;
17551755
}
17561756

1757-
throwIfInfiniteUpdateLoopDetected();
1757+
throwIfInfiniteUpdateLoopDetected(true);
17581758
}
17591759
}
17601760

@@ -1773,7 +1773,7 @@ function markRootPinged(root: FiberRoot, pingedLanes: Lanes) {
17731773
didIncludeCommitPhaseUpdate = true;
17741774
}
17751775

1776-
throwIfInfiniteUpdateLoopDetected();
1776+
throwIfInfiniteUpdateLoopDetected(true);
17771777
}
17781778
}
17791779

@@ -5175,7 +5175,9 @@ export function resolveRetryWakeable(boundaryFiber: Fiber, wakeable: Wakeable) {
51755175
retryTimedOutBoundary(boundaryFiber, retryLane);
51765176
}
51775177

5178-
export function throwIfInfiniteUpdateLoopDetected() {
5178+
export function throwIfInfiniteUpdateLoopDetected(
5179+
isFromInfiniteRenderLoopDetectionInstrumentation: boolean,
5180+
) {
51795181
if (nestedUpdateCount > NESTED_UPDATE_LIMIT) {
51805182
nestedUpdateCount = 0;
51815183
nestedPassiveUpdateCount = 0;
@@ -5187,7 +5189,10 @@ export function throwIfInfiniteUpdateLoopDetected() {
51875189

51885190
if (enableInfiniteRenderLoopDetection) {
51895191
if (updateKind === NESTED_UPDATE_SYNC_LANE) {
5190-
if (executionContext & RenderContext && workInProgressRoot !== null) {
5192+
if (
5193+
isFromInfiniteRenderLoopDetectionInstrumentation ||
5194+
(executionContext & RenderContext && workInProgressRoot !== null)
5195+
) {
51915196
// This loop was identified only because of the instrumentation gated with enableInfiniteRenderLoopDetection, warn instead of throwing.
51925197
if (__DEV__) {
51935198
console.error(

0 commit comments

Comments
 (0)