Reconciler: Don't retry synchronous render#41
Draft
everettbu wants to merge 4 commits into
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Mirror of facebook/react#28810
Original author: eps1lon
Summary
In react/react#13041 we started retrying the render synchronously if a render threw during a concurrent render. However, this also applied to synchronous renders which should help very rarely since we don't support mutations during render. The original PR even explicitly said that a synchronous render should not be retried. We also didn't used to retry in legacy roots: https://react-error-recovery-showcase.vercel.app/
A lot of tests asserted on the retry even though their render was sync i.e. not wrapped in
startTransition.I originally caught this while investigating duplicate host instance creation in error boundary fallbacks. But this is expected by proxy of having error recovery for sync renders. Host instances are created during render phase.
How did you test this change?
[ ] Codesandbox in Bug: Elements in ErrorBoundary are created twice, one of them becomes an orphan react/react#26518 no longer callsWe also create host instances twice when recovering from an error during concurrent render. We just never mutate the DOM twice. Creating host instances during render is intentional and documenteddocument.createElementtwice