Skip to content

Preserve the rendered shell on synchronous prerender abort - #37853

Merged
gnoff merged 8 commits into
react:mainfrom
gnoff:jstory/fizz-sync-abort-precise-postpone
Oct 19, 2026
Merged

gnoff merged 8 commits into
react:mainfrom
gnoff:jstory/fizz-sync-abort-precise-postpone

Conversation

@gnoff

@gnoff gnoff commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

#37709 showed that a synchronous prerender abort can discard a retried task's rendered shell, then resume only an inner slot. #37710 addressed the missing markup by postponing the whole task, but that could overlap replay paths from child tasks; #37852 reverted that approach.

Preserve the parent segment and continue rendering its text and host elements after abort. When a component or other render callback returns after abort, discard its children and track a postponed hole at that node. This includes function and class components, lazy and forward-ref components, Context.Consumer render props, iterables, and thenables. Already-created arrays are read normally; getters and host prop serialization follow React's render-purity rules. SuspenseList rows use the same postponement path and existing row task bookkeeping.

Preserve individual holes only while rendering an unfinished Suspense boundary. Tasks without a blocked boundary unwind through the existing root abort path: a postponed root cannot flush any shell and must render again in full. Tests cover root aborts during the initial render, in a retried child, and during a subsequent resumeAndPrerender, followed by a complete final resume.

This restores the tests from #37710, #37850, and #37851 and adds coverage for indexed retries, static host children after abort, iterators and thenables, forward refs, render-phase updates, nested fallbacks, and SuspenseList rows. A full-flow regression for repeated aborts during resumeAndPrerender is marked it.failing: it exposes an existing bug in postponing an already emitted boundary, fixed separately in #37876.

The browser prerender suite passes in development and production on stable and experimental channels, including the expected failure. ESLint and Prettier pass.

@meta-cla meta-cla Bot added the CLA Signed label Oct 14, 2026
@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Comparing: 99c106c...e25c93d

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 = 7.35 kB 7.35 kB -0.10% 1.96 kB 1.96 kB
oss-stable/react-dom/cjs/react-dom-client.production.js = 626.10 kB 626.10 kB = 110.63 kB 110.63 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 7.36 kB 7.36 kB -0.05% 1.96 kB 1.96 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js = 697.31 kB 697.31 kB = 122.07 kB 122.07 kB
facebook-www/ReactDOM-prod.classic.js = 715.35 kB 715.35 kB = 125.14 kB 125.14 kB
facebook-www/ReactDOM-prod.modern.js = 705.66 kB 705.66 kB = 123.57 kB 123.57 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
oss-experimental/react-server/cjs/react-server.production.js +1.08% 159.77 kB 161.49 kB +0.49% 28.23 kB 28.37 kB
oss-stable-semver/react-server/cjs/react-server.production.js +0.85% 155.94 kB 157.27 kB +0.40% 27.45 kB 27.56 kB
oss-stable/react-server/cjs/react-server.production.js +0.85% 155.94 kB 157.27 kB +0.40% 27.45 kB 27.56 kB
oss-experimental/react-server/cjs/react-server.development.js +0.84% 228.55 kB 230.47 kB +0.27% 40.13 kB 40.23 kB
oss-experimental/react-markup/cjs/react-markup.production.js +0.66% 256.62 kB 258.32 kB +0.28% 47.54 kB 47.67 kB
oss-stable-semver/react-server/cjs/react-server.development.js +0.65% 223.47 kB 224.91 kB +0.33% 39.15 kB 39.28 kB
oss-stable/react-server/cjs/react-server.development.js +0.65% 223.47 kB 224.91 kB +0.33% 39.15 kB 39.28 kB
oss-experimental/react-dom/cjs/react-dom-server-legacy.browser.production.js +0.63% 268.94 kB 270.64 kB +0.32% 48.13 kB 48.29 kB
oss-experimental/react-dom/cjs/react-dom-server-legacy.node.production.js +0.62% 274.88 kB 276.58 kB +0.24% 50.38 kB 50.51 kB
oss-experimental/react-dom/cjs/react-dom-server.browser.production.js +0.57% 299.83 kB 301.52 kB +0.24% 53.12 kB 53.24 kB
oss-experimental/react-dom/cjs/react-dom-server.bun.production.js +0.56% 300.46 kB 302.16 kB +0.23% 53.00 kB 53.12 kB
oss-experimental/react-dom/cjs/react-dom-server.edge.production.js +0.55% 306.80 kB 308.50 kB +0.22% 55.81 kB 55.93 kB
oss-experimental/react-dom/cjs/react-dom-server.node.production.js +0.54% 314.36 kB 316.06 kB +0.23% 55.59 kB 55.72 kB
facebook-www/ReactDOMServer-prod.classic.js +0.52% 268.29 kB 269.68 kB +0.26% 47.88 kB 48.00 kB
oss-stable-semver/react-dom/cjs/react-dom-server-legacy.browser.production.js +0.51% 258.82 kB 260.15 kB +0.28% 46.63 kB 46.77 kB
oss-stable/react-dom/cjs/react-dom-server-legacy.browser.production.js +0.51% 258.85 kB 260.18 kB +0.29% 46.66 kB 46.79 kB
oss-stable-semver/react-dom/cjs/react-dom-server-legacy.node.production.js +0.50% 264.18 kB 265.51 kB +0.23% 48.70 kB 48.81 kB
oss-stable/react-dom/cjs/react-dom-server-legacy.node.production.js +0.50% 264.21 kB 265.54 kB +0.23% 48.72 kB 48.83 kB
facebook-www/ReactDOMServer-prod.modern.js +0.50% 265.96 kB 267.29 kB +0.27% 47.52 kB 47.65 kB
facebook-www/ReactDOMServerStreaming-prod.modern.js +0.48% 278.22 kB 279.54 kB +0.22% 50.78 kB 50.89 kB
oss-experimental/react-markup/cjs/react-markup.development.js +0.47% 409.42 kB 411.34 kB +0.22% 73.98 kB 74.14 kB
oss-stable-semver/react-dom/cjs/react-dom-server.browser.production.js +0.46% 286.71 kB 288.04 kB +0.27% 51.17 kB 51.31 kB
oss-stable/react-dom/cjs/react-dom-server.browser.production.js +0.46% 286.79 kB 288.11 kB +0.26% 51.20 kB 51.33 kB
oss-stable-semver/react-dom/cjs/react-dom-server.bun.production.js +0.46% 287.54 kB 288.87 kB +0.23% 50.98 kB 51.10 kB
oss-stable/react-dom/cjs/react-dom-server.bun.production.js +0.46% 287.61 kB 288.94 kB +0.23% 51.01 kB 51.12 kB
oss-stable-semver/react-dom/cjs/react-dom-server.edge.production.js +0.45% 293.01 kB 294.34 kB +0.25% 53.54 kB 53.68 kB
oss-stable/react-dom/cjs/react-dom-server.edge.production.js +0.45% 293.09 kB 294.42 kB +0.25% 53.57 kB 53.70 kB
oss-experimental/react-markup/cjs/react-markup.react-server.production.js +0.45% 380.67 kB 382.37 kB +0.19% 70.72 kB 70.85 kB
oss-stable-semver/react-dom/cjs/react-dom-server.node.production.js +0.44% 300.95 kB 302.28 kB +0.25% 53.38 kB 53.51 kB
oss-stable/react-dom/cjs/react-dom-server.node.production.js +0.44% 301.02 kB 302.35 kB +0.25% 53.41 kB 53.54 kB
oss-experimental/react-dom/cjs/react-dom-server-legacy.node.development.js +0.44% 437.47 kB 439.39 kB +0.13% 78.45 kB 78.55 kB
oss-experimental/react-dom/cjs/react-dom-server-legacy.browser.development.js +0.44% 437.47 kB 439.39 kB +0.13% 78.45 kB 78.55 kB
oss-experimental/react-dom/cjs/react-dom-server.browser.development.js +0.41% 470.59 kB 472.51 kB +0.12% 83.45 kB 83.54 kB
oss-experimental/react-dom/cjs/react-dom-server.edge.development.js +0.41% 471.60 kB 473.52 kB +0.12% 83.67 kB 83.78 kB
oss-experimental/react-dom/cjs/react-dom-server.bun.development.js +0.41% 415.41 kB 417.10 kB +0.14% 78.44 kB 78.55 kB
oss-experimental/react-dom/cjs/react-dom-server.node.development.js +0.40% 476.99 kB 478.91 kB +0.13% 83.43 kB 83.54 kB
facebook-www/ReactDOMServer-dev.classic.js +0.34% 436.38 kB 437.89 kB +0.16% 78.15 kB 78.27 kB
oss-stable-semver/react-dom/cjs/react-dom-server-legacy.node.development.js +0.34% 421.78 kB 423.23 kB +0.17% 76.15 kB 76.28 kB
oss-stable-semver/react-dom/cjs/react-dom-server-legacy.browser.development.js +0.34% 421.79 kB 423.23 kB +0.17% 76.15 kB 76.28 kB
oss-stable/react-dom/cjs/react-dom-server-legacy.node.development.js +0.34% 421.81 kB 423.25 kB +0.17% 76.17 kB 76.30 kB
oss-stable/react-dom/cjs/react-dom-server-legacy.browser.development.js +0.34% 421.81 kB 423.26 kB +0.17% 76.18 kB 76.30 kB
facebook-www/ReactDOMServer-dev.modern.js +0.33% 432.93 kB 434.37 kB +0.17% 77.56 kB 77.69 kB
facebook-www/ReactDOMServerStreaming-dev.modern.js +0.33% 439.21 kB 440.66 kB +0.17% 78.57 kB 78.70 kB
oss-stable-semver/react-dom/cjs/react-dom-server.bun.development.js +0.33% 399.48 kB 400.79 kB +0.13% 75.78 kB 75.88 kB
oss-stable/react-dom/cjs/react-dom-server.bun.development.js +0.33% 399.56 kB 400.87 kB +0.13% 75.81 kB 75.91 kB
oss-stable-semver/react-dom/cjs/react-dom-server.browser.development.js +0.32% 452.38 kB 453.82 kB +0.14% 80.82 kB 80.94 kB
oss-stable/react-dom/cjs/react-dom-server.browser.development.js +0.32% 452.45 kB 453.90 kB +0.14% 80.88 kB 80.99 kB
oss-stable-semver/react-dom/cjs/react-dom-server.edge.development.js +0.32% 453.17 kB 454.61 kB +0.15% 81.01 kB 81.13 kB
oss-stable/react-dom/cjs/react-dom-server.edge.development.js +0.32% 453.24 kB 454.69 kB +0.14% 81.07 kB 81.18 kB
oss-stable-semver/react-dom/cjs/react-dom-server.node.development.js +0.31% 459.06 kB 460.50 kB +0.15% 80.75 kB 80.87 kB
oss-stable/react-dom/cjs/react-dom-server.node.development.js +0.31% 459.13 kB 460.58 kB +0.15% 80.80 kB 80.92 kB
oss-experimental/react-markup/cjs/react-markup.react-server.development.js +0.27% 715.96 kB 717.88 kB +0.07% 126.83 kB 126.93 kB

Generated by sizebot against e25c93d

@github-actions github-actions Bot added the React Core Team Opened by a member of the React Core Team label Oct 14, 2026
@gnoff
gnoff force-pushed the jstory/fizz-sync-abort-precise-postpone branch 10 times, most recently from 864daa4 to 12c9e7d Compare October 15, 2026 00:18
A synchronous abort currently discards an entire retried task, so resuming a deeper slot can omit markup rendered earlier in that task. Keep the parent segment and postpone individual nodes whose user code returns after abort while allowing existing text and host elements to complete. This addresses react#37709 without overlapping parent and child replay paths.

Restore the regression tests from react#37710, react#37850, and react#37851 and cover indexed retries, static host children, callback results, and abort traversal. Render-phase updates may finish after abort, but their returned children are discarded before entering the model. SuspenseList rows retain their separate completion handling.
@gnoff
gnoff force-pushed the jstory/fizz-sync-abort-precise-postpone branch from 12c9e7d to 9b4720d Compare October 15, 2026 14:52
gnoff added 3 commits October 15, 2026 08:52
An abort can unwind through a component after the task has advanced to its returned children. Using the enclosing render call's node and child index with that deeper key path records an incorrect replay slot and can omit content when resuming.

Create postponed tasks from the same retry state as suspended tasks and finish them immediately. Cover an aborting iterable returned by a component among siblings, and allow nested fallback segments to use the same postponement path.

Verified browser prerender tests in development and production (47 each), ESLint, and Prettier.
Continue traversing SuspenseList after a synchronous prerender abort so static row content is preserved and user-code results leave resumable holes. Use the existing row task bookkeeping instead of postponing the entire list or unwinding out of a row.

Restore context directly in the handled postponement branch and rename the helper to postponeNewSuspendedRenderTask. Cover aborts before a list, inside a row, and in a Suspense fallback across forwards, backwards, and together reveal orders.

Verified 55 browser prerender tests in development and production, 13 existing SuspenseList tests, ESLint, and Prettier.
An assigned segment ID identifies an existing placeholder and does not prevent its content from containing new postponed holes. Remove that exclusion from synchronous prerender abort handling.

Extend the repeated-abort regression through the complete prerender, resumeAndPrerender, and final resume flow. Mark it as expected failing while a separate fix addresses the existing API bug when postponing the same boundary again.
gnoff added 4 commits October 16, 2026 09:45
Discard user-code results uniformly after a synchronous prerender abort and let the existing task finalizer decide whether that work postpones or switches to client rendering. The abort reason should not determine how far the current render unwinds.

Remove the redundant browser-specific exclusion from renderNode. Browser aborts still select client rendering and their existing diagnostic routing through finishAbortedTask.
The regression from react#37710 asserts that resuming after an abort during a retried task preserves its parent markup. Name the test after that observable behavior rather than the reverted fix's strategy of resuming the task from where it started.
Allow aborted prerender tasks outside Suspense to use the same postponement path. When a child postpones before the root finishes, honor the recorded root halt so partial root markup cannot flush.

Cover synchronous root aborts during the initial render and in a retried child task, including resuming both to the complete output.
Preserve individual postponed holes only while rendering an unfinished Suspense boundary. A postponed root cannot flush a shell and must render again in full, so use the existing root abort path and remove the extra root completion bookkeeping.

Keep the root abort regressions and cover a second synchronous abort during resumeAndPrerender before the final full-root resume.
@gnoff
gnoff merged commit ba39b32 into react:main Oct 19, 2026
239 checks passed
github-actions Bot pushed a commit that referenced this pull request Oct 19, 2026
#37709 showed that a synchronous prerender abort can discard a retried
task's rendered shell, then resume only an inner slot. #37710 addressed
the missing markup by postponing the whole task, but that could overlap
replay paths from child tasks; #37852 reverted that approach.

Preserve the parent segment and continue rendering its text and host
elements after abort. When a component or other render callback returns
after abort, discard its children and track a postponed hole at that
node. This includes function and class components, lazy and forward-ref
components, Context.Consumer render props, iterables, and thenables.
Already-created arrays are read normally; getters and host prop
serialization follow React's render-purity rules. SuspenseList rows use
the same postponement path and existing row task bookkeeping.

Preserve individual holes only while rendering an unfinished Suspense
boundary. Tasks without a blocked boundary unwind through the existing
root abort path: a postponed root cannot flush any shell and must render
again in full. Tests cover root aborts during the initial render, in a
retried child, and during a subsequent resumeAndPrerender, followed by a
complete final resume.

This restores the tests from #37710, #37850, and #37851 and adds
coverage for indexed retries, static host children after abort,
iterators and thenables, forward refs, render-phase updates, nested
fallbacks, and SuspenseList rows. A full-flow regression for repeated
aborts during resumeAndPrerender is marked `it.failing`: it exposes an
existing bug in postponing an already emitted boundary, fixed separately
in #37876.

The browser prerender suite passes in development and production on
stable and experimental channels, including the expected failure. ESLint
and Prettier pass.

DiffTrain build for [ba39b32](ba39b32)
gnoff added a commit that referenced this pull request Oct 19, 2026
`resumeAndPrerender` fails when the same already emitted Suspense
boundary needs to postpone again. This predates #37853: prerendering a
suspended boundary, aborting, resuming it while it still suspends, and
aborting again hits the missing postponement metadata even when both
aborts happen outside rendering.

Initialize tracking for resumed boundaries and preserve the boundary ID
already referenced by the emitted HTML. When a pass finishes with
postponed holes, flush completed segments as partial output and retain
the fallback until a later resume completes the boundary.

Switch the full-flow regression from #37853 from `it.failing` to `it`,
asserting prerender → resumeAndPrerender → final resume, intermediate
HTML, JSON round trips, and removal of placeholders. Add a regression
using external aborts to directly cover the existing API bug. Also
verify that one resumed boundary can complete while a sibling aborts and
postpones again, both at the root and through an already completed
Suspense ancestor.

Follow-up to the merged #37853. This PR contains only the
resumeAndPrerender fix and its regression tests.

The browser prerender suite passes in development and production on
stable and experimental channels. ESLint and Prettier pass.
github-actions Bot pushed a commit that referenced this pull request Oct 19, 2026
`resumeAndPrerender` fails when the same already emitted Suspense
boundary needs to postpone again. This predates #37853: prerendering a
suspended boundary, aborting, resuming it while it still suspends, and
aborting again hits the missing postponement metadata even when both
aborts happen outside rendering.

Initialize tracking for resumed boundaries and preserve the boundary ID
already referenced by the emitted HTML. When a pass finishes with
postponed holes, flush completed segments as partial output and retain
the fallback until a later resume completes the boundary.

Switch the full-flow regression from #37853 from `it.failing` to `it`,
asserting prerender → resumeAndPrerender → final resume, intermediate
HTML, JSON round trips, and removal of placeholders. Add a regression
using external aborts to directly cover the existing API bug. Also
verify that one resumed boundary can complete while a sibling aborts and
postpones again, both at the root and through an already completed
Suspense ancestor.

Follow-up to the merged #37853. This PR contains only the
resumeAndPrerender fix and its regression tests.

The browser prerender suite passes in development and production on
stable and experimental channels. ESLint and Prettier pass.

DiffTrain build for [e92156b](e92156b)
eps1lon pushed a commit to vercel/next.js that referenced this pull request Oct 20, 2026
[diff
react/react@99c106c4...ba39b32a](react/react@99c106c...ba39b32)

<details>
<summary>React upstream changes</summary>

- react/react#37853
- react/react#37856
- react/react#37855

</details>

---------

Co-authored-by: next-js-bot[bot] <279046576+next-js-bot[bot]@users.noreply.github.com>
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.

2 participants