Skip to content

fix: explicitly warn for infinite loops discovered only via enableInfiniteRenderLoopDetection#36195

Open
hoxyq wants to merge 1 commit intomainfrom
infinite-render-loop/warn-fix
Open

fix: explicitly warn for infinite loops discovered only via enableInfiniteRenderLoopDetection#36195
hoxyq wants to merge 1 commit intomainfrom
infinite-render-loop/warn-fix

Conversation

@hoxyq
Copy link
Copy Markdown
Contributor

@hoxyq hoxyq commented Apr 2, 2026

My change in #35999 did not cover all possible scenarios for emitting a warning, instead of throwing.

The instrumentation not only enables the identification for the infinite loop via execution context checks, but also adds the check to more lifecycle methods, like markRootPinged and markRootUpdated.

See the newly added test to understand a potential scenario. Before the fix, the error would be thrown:
Screenshot 2026-04-08 at 17 21 51

With the current changes, the warning is logged with consolel.error.

@hoxyq hoxyq requested review from jackpope and rickhanlonii April 2, 2026 13:00
@meta-cla meta-cla bot added the CLA Signed label Apr 2, 2026
@react-sizebot
Copy link
Copy Markdown

react-sizebot commented Apr 2, 2026

Comparing: 0c44b96...90fd0c0

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.js = 6.84 kB 6.84 kB = 1.88 kB 1.88 kB
oss-stable/react-dom/cjs/react-dom-client.production.js = 612.91 kB 612.91 kB = 108.30 kB 108.30 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 6.84 kB 6.84 kB = 1.88 kB 1.88 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js = 678.85 kB 678.85 kB = 119.27 kB 119.27 kB
facebook-www/ReactDOM-prod.classic.js +0.02% 698.24 kB 698.38 kB +0.02% 122.65 kB 122.68 kB
facebook-www/ReactDOM-prod.modern.js +0.02% 688.55 kB 688.69 kB +0.03% 121.03 kB 121.06 kB

Significant size changes

Includes any change greater than 0.2%:

(No significant changes)

Generated by 🚫 dangerJS against 90fd0c0

@rickhanlonii
Copy link
Copy Markdown
Member

I need some tests to understand what wasn't covered before and what's covered now

@hoxyq hoxyq force-pushed the infinite-render-loop/warn-fix branch from 8d8ef64 to d22ee6a Compare April 8, 2026 17:02
@hoxyq
Copy link
Copy Markdown
Contributor Author

hoxyq commented Apr 8, 2026

I need some tests to understand what wasn't covered before and what's covered now

@rickhanlonii, I've added a test that reproduces the previously failing scenario. Please see the updated summary as well.

@hoxyq hoxyq force-pushed the infinite-render-loop/warn-fix branch 2 times, most recently from 2b9b20a to 4ec0db7 Compare April 8, 2026 17:16
@hoxyq hoxyq force-pushed the infinite-render-loop/warn-fix branch from 4ec0db7 to 90fd0c0 Compare April 8, 2026 17:23
});

it('warns instead of throwing when infinite Suspense ping loop is detected via enableInfiniteRenderLoopDetection during commit phase', async () => {
if (!__DEV__ || gate(flags => !flags.enableInfiniteRenderLoopDetection)) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this use @gate pragma?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants