Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect loops caused by updates during prerender #31445

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

acdlite
Copy link
Collaborator

@acdlite acdlite commented Nov 7, 2024

When Meta tried rolling out enableSiblingPrerendering internally, there were reports of infinite render loops that we suspect were caused by updates triggered during the render phase. While we don't have an exact repro, we know that theoretically this is possible because any update, included one triggered as a side effect of rendering, will interrupt an in-progress prerender.

Although we already have warnings and protections against updates that occur during the render phase, the sibling prerendering experiment introduces new scenarios that could cause previously working (though technically incorrect) product code to regress.

The solution in this PR is to maintain a counter of how many times a prerender is interrupted before it successfully completes. Once the counter reaches that threshold, we disable the prerendering mechanism, effectively reverting to the behavior that's in canary today.

The counter is reset the next time the update queue is exhausted, allowing for subsequent prerenders to work as before.

Copy link

vercel bot commented Nov 7, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-compiler-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 7, 2024 5:11am

@react-sizebot
Copy link

react-sizebot commented Nov 7, 2024

Comparing: e137890...70d029b

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.68 kB 6.68 kB +0.05% 1.82 kB 1.83 kB
oss-stable/react-dom/cjs/react-dom-client.production.js +0.01% 506.41 kB 506.48 kB +0.04% 90.49 kB 90.52 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 6.69 kB 6.69 kB = 1.83 kB 1.83 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js +0.01% 511.34 kB 511.41 kB +0.04% 91.20 kB 91.23 kB
facebook-www/ReactDOM-prod.classic.js +0.05% 602.31 kB 602.61 kB +0.05% 106.33 kB 106.38 kB
facebook-www/ReactDOM-prod.modern.js +0.05% 578.34 kB 578.64 kB +0.05% 102.41 kB 102.47 kB

Significant size changes

Includes any change greater than 0.2%:

(No significant changes)

Generated by 🚫 dangerJS against c425c60

When Meta tried rolling out enableSiblingPrerendering internally, there
were reports of infinite render loops that we suspect were caused by
updates triggered during the render phase. While we don't have an
exact repro, we know that theoretically this is possible because any
update, included one triggered as a side effect of rendering, will
interrupt an in-progress prerender.

Although we already have warnings and protections against updates that
occur during the render phase, the sibling prerendering experiment
introduces new scenarios that could cause previously working (though
technically incorrect) product code to regress.

The solution in this PR is to maintain a counter of how many times a
prerender is interrupted before it successfully completes. Once the
counter reaches that threshold, we disable the prerendering mechanism,
effectively reverting to the behavior that's in canary today.

The counter is reset the next time the update queue is exhausted,
allowing for subsequent prerenders to work as before.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed React Core Team Opened by a member of the React Core Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants