Skip to content

Prune descendant replay paths after a parent postpone - #37851

Closed
gnoff wants to merge 1 commit into
react:mainfrom
gnoff:jstory/fizz-prune-overlapping-replay-nodes
Closed

gnoff wants to merge 1 commit into
react:mainfrom
gnoff:jstory/fizz-prune-overlapping-replay-nodes

Conversation

@gnoff

@gnoff gnoff commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator

Follow-up to #37850. Extracting the suspended and aborting children into a component still leaves a nested child replay path beneath a Suspense boundary whose whole content was postponed. Resume rerenders that content but then finds the stale child path, reports a replay mismatch, and leaves the fallback visible.

When recording a whole-content replay slot, clear descendant replay paths already tracked and avoid attaching later paths beneath it. The new regression test wraps the children in a component and verifies that both render after resume.

Tests:

  • yarn test ReactDOMFizzStatic --runInBand (60 passed)
  • yarn test ReactDOMFizzStatic --prod --runInBand (60 passed)
  • yarn test ReactDOMFizzSuspenseList --runInBand (13 passed)
  • yarn linc
  • node scripts/prettier/index.js check-changed
  • yarn flow dom-node

A prerender abort can leave a suspended child task under an ancestor that is postponed as a whole. The earlier fix ignores a duplicate slot at the same key path, but extracting the children into a component gives the child a nested replay path. Resuming the ancestor then rerenders its subtree while the stale child path remains, causing a replay mismatch and leaving the Suspense fallback visible.

Clear descendant paths when recording a whole-content slot and avoid attaching new paths beneath it during later abort cleanup. Add a regression test with the children wrapped in a component.
@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: e25b4a4...a283dfe

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 = 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 = 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%:

(No significant changes)

Generated by sizebot against a283dfe

@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 closed this Oct 14, 2026
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.
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.

1 participant