Skip to content

Preserve SSR Suspense fallback across client re-suspend (#37620) - #37694

Open
theworker02 wants to merge 1 commit into
react:mainfrom
theworker02:fix/suspense-fallback-hydration-remount-37620
Open

theworker02 wants to merge 1 commit into
react:mainfrom
theworker02:fix/suspense-fallback-hydration-remount-37620

Conversation

@theworker02

Copy link
Copy Markdown

Summary

  • Fixes Bug: Suspense fallback remounts on hydration after use(browser()) + client use(promise) #37620 (BountyHub $100): when use(browser()) leaves a permanent SSR Suspense fallback and hydration re-suspends on a client-created promise (setTimeout / localStorage / IndexedDB shape), keep the dehydrated fallback DOM mounted instead of deleting and remounting an identical fallback.
  • Remounting restarted CSS animations (Progress) and dropped DOM state even though the visible UI looked unchanged.
  • Gate is tight to the recoverable browser() digest so ordinary error fallbacks still take the existing client-render path.

Implementation

In updateDehydratedSuspenseComponent, when a permanent fallback re-suspends on the client:

  1. Drop the dehydrated fragment from pending deletions.
  2. Mount a hidden primary Offscreen fiber for the retry.
  3. Reuse the existing dehydrated fallback sibling instead of creating a new fallback fragment.

Also teach updateSuspenseFallbackChildren / bailoutOffscreenComponent not to treat a preserved DehydratedFragment as renderable children.

Test plan

  • yarn test --build=false ReactDOMFizzServer-test --testNamePattern="browser-only|does not remount|replaces the SSR|keeps the SSR fallback" → 7 passed
  • New regression: client promise after use(browser()) keeps the same <span> node identity across hydration
  • Control: hydration that finishes without re-suspending still replaces the SSR fallback
  • Multi-suspend: fallback identity preserved across sequential client promises

Bounty

Claiming the BountyHub bounty on #37620.

@meta-cla

meta-cla Bot commented Sep 26, 2026

Copy link
Copy Markdown

Hi @theworker02!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@github-actions

github-actions Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

Warning

These sizes are for f6ad245, which is no longer the head of this pull request.

A build for 3664ce5 is in progress.

The build for this commit did not complete, so there is no size report. See the workflow run for details.

Generated by sizebot against f6ad245

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

meta-cla Bot commented Oct 14, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

When use(browser()) paints a permanent SSR fallback and hydration
re-suspends on a client-created promise, keep the dehydrated fallback
DOM mounted so CSS animations and local DOM state are not reset.

Co-authored-by: Cursor <[email protected]>
@theworker02
theworker02 force-pushed the fix/suspense-fallback-hydration-remount-37620 branch from f6ad245 to 3664ce5 Compare November 26, 2026 11:55

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Suspense fallback remounts on hydration after use(browser()) + client use(promise)

1 participant