Reconciler: Don't retry synchronous render
Summary
In https://github.com/facebook/react/pull/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 https://github.com/facebook/react/issues/26518 no longer calls
document.createElementtwice~ We 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 documented - Adjusted tests to not assert that sync render retries
Comparing: 5b903cdaa94c78e8fabb985d8daca5bd7d266323...00d183b038af59f953cc12f444d562e5d463ef5c
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 | +0.04% | 497.54 kB | 497.71 kB | +0.05% | 88.93 kB | 88.98 kB |
| oss-experimental/react-dom/cjs/react-dom.production.js | +0.03% | 502.86 kB | 503.04 kB | +0.05% | 89.84 kB | 89.88 kB |
| facebook-www/ReactDOM-prod.classic.js | +0.03% | 591.00 kB | 591.18 kB | +0.04% | 103.95 kB | 103.99 kB |
| facebook-www/ReactDOM-prod.modern.js | +0.03% | 566.82 kB | 566.99 kB | +0.06% | 100.15 kB | 100.21 kB |
| test_utils/ReactAllWarnings.js | Deleted | 64.68 kB | 0.00 kB | Deleted | 16.15 kB | 0.00 kB |
Significant size changes
Includes any change greater than 0.2%:
Expand to show
| Name | +/- | Base | Current | +/- gzip | Base gzip | Current gzip |
|---|---|---|---|---|---|---|
| test_utils/ReactAllWarnings.js | Deleted | 64.68 kB | 0.00 kB | Deleted | 16.15 kB | 0.00 kB |
Generated by :no_entry_sign: dangerJS against 00d183b038af59f953cc12f444d562e5d463ef5c