Skip to content

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

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

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

Conversation

@sidshehria

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 with browser-only / remount / SSR fallback patterns → 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.

When use(browser()) leaves a permanent SSR fallback and hydration
re-suspends on a client-created promise, keep the dehydrated fallback
DOM mounted instead of deleting and remounting an identical fallback
that restarts CSS animations.

Co-authored-by: Cursor <[email protected]>
@meta-cla

meta-cla Bot commented Sep 28, 2026

Copy link
Copy Markdown

Hi @sidshehria!

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 28, 2026 •

Copy link
Copy Markdown

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

Generated by sizebot against 572b3d7

@meta-cla

meta-cla Bot commented Sep 28, 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!

@meta-cla meta-cla Bot added the CLA Signed label Sep 28, 2026
@sidshehria

Copy link
Copy Markdown
Author

please review

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