Repository navigation
Preserve the rendered shell on synchronous prerender abort - #37853
Merged
Merged
Conversation
gnoff
force-pushed
the
jstory/fizz-sync-abort-precise-postpone
branch
10 times, most recently
from
October 15, 2026 00:18
864daa4 to
12c9e7d
Compare
eps1lon
approved these changes
Oct 15, 2026
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
force-pushed
the
jstory/fizz-sync-abort-precise-postpone
branch
from
October 15, 2026 14:52
12c9e7d to
9b4720d
Compare
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.
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.
eps1lon
approved these changes
Oct 17, 2026
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>
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.
#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.