Skip to content

Fix overlapping replay slots after a prerender abort - #37850

Merged
gnoff merged 1 commit into
react:mainfrom
gnoff:jstory/fizz-overlapping-postpones
Oct 14, 2026
Merged

gnoff merged 1 commit into
react:mainfrom
gnoff:jstory/fizz-overlapping-postpones

Conversation

@gnoff

@gnoff gnoff commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator

Summary

A prerender can abort during a retry after the retried task has spawned a suspended child. Abort cleanup records a replay slot for the whole task, then tries to record a child slot at the same key path. Resuming the parent already renders that child, so the existing assertion turns a resumable abort into a prerender error. This surfaced after the abort unwind change in #37710.

Keep the parent slot and ignore the redundant child slot. The regression test verifies that both children render after resuming.

How did you test this change?

  • yarn test ReactDOMFizzStaticBrowser --runInBand (36 passed)
  • yarn test ReactDOMFizzStaticBrowser --prod --runInBand (36 passed)
  • yarn linc
  • node scripts/prettier/index.js check-changed

@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

No build was found for the base commit (0c9913a) that this pull request diverged from, so there is no size report. The build for that commit may have failed, or its artifacts may be older than the retention window. Rebase the pull request onto a newer main to compare against a base commit that has a build.

Generated by sizebot against a9d7404

@github-actions github-actions Bot added the React Core Team Opened by a member of the React Core Team label Oct 14, 2026
);
// The parent task was aborted after it spawned this child task.
// Resuming the parent also renders this child, so its slot is redundant.
return;

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This invariant was more important when we had a React.postpone() API however now the only postpones that are tracked are during prerender aborts and we now are in a position where the slots are restored on abort after a task is spawned and we want to take it preferentially

A prerender can abort while retrying a task after it has spawned a suspended child. Abort cleanup then records both a slot for the parent and a slot for that child, even though resuming the parent renders the child again. This collision currently throws and prevents the prerender from resuming.

Keep the parent slot and ignore the redundant child slot. Add a regression test that aborts during the retry and verifies both children render after resume.
@gnoff
gnoff force-pushed the jstory/fizz-overlapping-postpones branch from 7d4065e to a9d7404 Compare October 14, 2026 20:48
@gnoff
gnoff merged commit e25b4a4 into react:main Oct 14, 2026
239 checks passed
github-actions Bot pushed a commit that referenced this pull request Oct 14, 2026
## Summary

A prerender can abort during a retry after the retried task has spawned
a suspended child. Abort cleanup records a replay slot for the whole
task, then tries to record a child slot at the same key path. Resuming
the parent already renders that child, so the existing assertion turns a
resumable abort into a prerender error. This surfaced after the abort
unwind change in #37710.

Keep the parent slot and ignore the redundant child slot. The regression
test verifies that both children render after resuming.

## How did you test this change?

- `yarn test ReactDOMFizzStaticBrowser --runInBand` (36 passed)
- `yarn test ReactDOMFizzStaticBrowser --prod --runInBand` (36 passed)
- `yarn linc`
- `node scripts/prettier/index.js check-changed`

DiffTrain build for [e25b4a4](e25b4a4)
github-actions Bot pushed a commit that referenced this pull request Oct 14, 2026
## Summary

A prerender can abort during a retry after the retried task has spawned
a suspended child. Abort cleanup records a replay slot for the whole
task, then tries to record a child slot at the same key path. Resuming
the parent already renders that child, so the existing assertion turns a
resumable abort into a prerender error. This surfaced after the abort
unwind change in #37710.

Keep the parent slot and ignore the redundant child slot. The regression
test verifies that both children render after resuming.

## How did you test this change?

- `yarn test ReactDOMFizzStaticBrowser --runInBand` (36 passed)
- `yarn test ReactDOMFizzStaticBrowser --prod --runInBand` (36 passed)
- `yarn linc`
- `node scripts/prettier/index.js check-changed`

DiffTrain build for [e25b4a4](e25b4a4)
gnoff added a commit that referenced this pull request Oct 14, 2026
Revert #37710 and #37850 while we revisit how synchronous prerender
aborts preserve replay state.

Restoring the aborted task root as a replay point can overlap postpones
from child tasks. #37850 suppresses one form of the overlap, but an
indexed parent slot can still coexist with a descendant replay node and
fail during resumption. This removes the incomplete change so we can
address the replay invariants together.

This deliberately restores the behavior reported in #37709: if a
prerender abort interrupts a task after it has rendered part of its
shell, the later resume can omit that markup. That regression needs a
follow-up fix.

This supersedes #37851.

Tests: `yarn test ReactDOMFizzStaticBrowser --runInBand` and `yarn test
ReactDOMFizzStaticBrowser --prod --runInBand` (34 passed in each mode).
github-actions Bot pushed a commit that referenced this pull request Oct 14, 2026
Revert #37710 and #37850 while we revisit how synchronous prerender
aborts preserve replay state.

Restoring the aborted task root as a replay point can overlap postpones
from child tasks. #37850 suppresses one form of the overlap, but an
indexed parent slot can still coexist with a descendant replay node and
fail during resumption. This removes the incomplete change so we can
address the replay invariants together.

This deliberately restores the behavior reported in #37709: if a
prerender abort interrupts a task after it has rendered part of its
shell, the later resume can omit that markup. That regression needs a
follow-up fix.

This supersedes #37851.

Tests: `yarn test ReactDOMFizzStaticBrowser --runInBand` and `yarn test
ReactDOMFizzStaticBrowser --prod --runInBand` (34 passed in each mode).

DiffTrain build for [99c106c](99c106c)
gnoff added a commit to gnoff/react that referenced this pull request Oct 14, 2026
A synchronous abort currently discards an entire retried task, so resuming a deeper slot can omit markup rendered earlier in that task. Preserve the completed shell by postponing the interrupted child and unvisited siblings without running more rendering code. This addresses react#37709 without restoring overlapping parent and child replay paths.

Restore the regressions from react#37710, react#37850, and react#37851 and cover indexed retries and abort traversal. Replay and SuspenseList tasks retain their existing abort path until their separate completion bookkeeping supports partial progress.
gnoff added a commit to gnoff/react that referenced this pull request Oct 14, 2026
A synchronous abort currently discards an entire retried task, so resuming a deeper slot can omit markup rendered earlier in that task. Preserve the completed shell by postponing the interrupted child and unvisited siblings without running more rendering code. This addresses react#37709 without restoring overlapping parent and child replay paths.

Restore the regressions from react#37710, react#37850, and react#37851 and cover indexed retries and abort traversal. Replay and SuspenseList tasks retain their existing abort path until their separate completion bookkeeping supports partial progress.
gnoff added a commit to gnoff/react that referenced this pull request Oct 14, 2026
A synchronous abort currently discards an entire retried task, so resuming a deeper slot can omit markup rendered earlier in that task. Preserve the parent segment by postponing interrupted and unvisited children, allowing the already-rendered host structure 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 and abort traversal. A component may finish its render-phase updates after abort, but its returned children are discarded before they enter the model. Replay and SuspenseList rows retain their existing completion handling.
gnoff added a commit to gnoff/react that referenced this pull request Oct 14, 2026
A synchronous abort currently discards an entire retried task, so resuming a deeper slot can omit markup rendered earlier in that task. Preserve the parent segment by postponing interrupted and unvisited children, allowing the already-rendered host structure 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 and abort traversal. A component may finish its render-phase updates after abort, but its returned children are discarded before they enter the model. Replay and SuspenseList rows retain their existing completion handling.
gnoff added a commit to gnoff/react that referenced this pull request Oct 14, 2026
A synchronous abort currently discards an entire retried task, so resuming a deeper slot can omit markup rendered earlier in that task. Preserve the parent segment by postponing interrupted and unvisited children, allowing the already-rendered host structure 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 and abort traversal. A component may finish its render-phase updates after abort, but its returned children are discarded before they enter the model. Replay and SuspenseList rows retain their existing completion handling.
gnoff added a commit to gnoff/react that referenced this pull request Oct 14, 2026
A synchronous abort currently discards an entire retried task, so resuming a deeper slot can omit markup rendered earlier in that task. Preserve the parent segment by postponing interrupted and later component work 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 after abort, and abort traversal. A component may finish its render-phase updates after abort, but its returned children are discarded before they enter the model. Replay and SuspenseList rows retain their existing completion handling.
gnoff added a commit to gnoff/react that referenced this pull request 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 added a commit to gnoff/react that referenced this pull request 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 added a commit to gnoff/react that referenced this pull request 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 added a commit to gnoff/react that referenced this pull request 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.
sokra pushed a commit to vercel/next.js that referenced this pull request Oct 15, 2026
[diff
react/react@07dde64d...99c106c4](react/react@07dde64...99c106c)

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

- react/react#37852
- react/react#37850
- react/react#37846
- react/react#37764

</details>

---------

Co-authored-by: next-js-bot[bot] <279046576+next-js-bot[bot]@users.noreply.github.com>
Co-authored-by: Josh Story <[email protected]>
gnoff added a commit to gnoff/react that referenced this pull request 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 added 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.
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)
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