GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Don't recreate the same fallback on the client if hydrating suspends by gaearon · Pull Request #24236 · react/react

Conversation

@gaearon

@gaearon gaearon commented Mar 31, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator

If the server errors (or if it suspends in renderToString, which is like erroring — there's never gonna be more content) within a Suspense boundary, we send its fallback to the client with a special marker. The client is supposed to retry rendering that Suspense boundary's content during hydration with a clean render and replace the DOM.

The question is what happens if hydrating suspends. Previously, we'd use the result of that clean render. However, the result is the same fallback. So we'd just replace a server fallback with the same client fallback. This would thrash the DOM, restart animations, etc. Since there is no reason to do this, in this PR, we instead throw away the commit and leave the server fallback in place. Then, when we're able to render the content, we commit that clean render and report the server error.

If there is another root update though, fallback props could've changed. E.g. theme switch. In that case we recreate it. (Unless it is a transition — that's not urgent, so it can wait.)

This fixes the case originally discovered in #24229. I've also added new tests just for this case.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@gaearon
Delay showing fallback if hydrating suspends
38b3038
@facebook-github-bot facebook-github-bot added the CLA Signed label Mar 31, 2022
@gaearon
gaearon requested review from acdlite and sebmarkbage March 31, 2022 21:02
@facebook-github-bot facebook-github-bot added the React Core Team Opened by a member of the React Core Team label Mar 31, 2022
acdlite
acdlite reviewed Mar 31, 2022
View reviewed changes
Comment thread packages/react-reconciler/src/ReactFiberLane.new.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

@sizebot

sizebot commented Mar 31, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Comparing: 4db3ff6...6cb9f18

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.min.js = 131.30 kB 131.30 kB +0.03% 41.96 kB 41.97 kB
oss-experimental/react-dom/cjs/react-dom.production.min.js = 136.36 kB 136.36 kB +0.01% 43.41 kB 43.42 kB
facebook-www/ReactDOM-prod.classic.js = 432.72 kB 432.75 kB = 79.59 kB 79.58 kB
facebook-www/ReactDOM-prod.modern.js = 417.72 kB 417.75 kB = 77.21 kB 77.21 kB
facebook-www/ReactDOMForked-prod.classic.js = 432.72 kB 432.75 kB = 79.59 kB 79.58 kB

Significant size changes

Includes any change greater than 0.2%:

(No significant changes)

Generated by 🚫 dangerJS against 6cb9f18

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gaearon
Fix up
a47c615
acdlite
acdlite approved these changes Mar 31, 2022
View reviewed changes

@acdlite acdlite left a comment •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

This makes sense to me. I'm a little suspicious of the renderDidSuspendDelayIfPossible call but there's already a known problem related to that, so I can take a look when I work on that fix.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@gaearon

gaearon commented Mar 31, 2022

Copy link
Copy Markdown
Collaborator Author

Let's get Seb to look at the changed tests since this call was his idea

acdlite reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

sebmarkbage
sebmarkbage approved these changes Mar 31, 2022
View reviewed changes

@sebmarkbage sebmarkbage left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

It would be nice to have a test that tests just the simple case. The server errors, the client is suspends but no errors. The fallback doesn’t get replaced. The it unsuspends.

With the rationale spelled out that we don’t want to interrupt animations in the fallback.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

gaearon reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread packages/react-dom/src/__tests__/ReactDOMHydrationDiff-test.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

@gaearon

gaearon commented Mar 31, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator Author

OK so I'll add tests for:

  1. Server errors, client doesn't but suspends. Client doesn't remount fallback because that would be silly.
  2. Server errors, client doesn't but suspends. Then new prop update making fallback a different color. Client remounts.

Sounds right @sebmarkbage ?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gaearon
Include all non-urgent lanes
6f96d0a
sebmarkbage
sebmarkbage approved these changes Apr 1, 2022
View reviewed changes
@gaearon
Moar tests
e6734cd
@gaearon
gaearon force-pushed the delay-fallback-hydration branch from da9f213 to e6734cd Compare April 1, 2022 01:09
@gaearon gaearon changed the title Delay showing fallback if hydrating suspends Don't recreate the same fallback on the client if hydrating suspends Apr 1, 2022
@gaearon
Add test for transitions
6cb9f18
@gaearon
gaearon merged commit ebd7ff6 into react:main Apr 1, 2022
@gaearon
gaearon deleted the delay-fallback-hydration branch April 1, 2022 01:50
facebook-github-bot pushed a commit to react/react-native that referenced this pull request Apr 12, 2022
@rickhanlonii @facebook-github-bot
React Native sync for revisions 34aa5cf...e8f4a66
46ab59c
Summary:
This sync includes the following changes:
- **[e8f4a66](react/react@e8f4a6653 )**: Fix import in example //<dan>//
- **[bb49abe](react/react@bb49abea2 )**: Update some READMEs ([#24290](react/react#24290)) //<dan>//
- **[4bc465a](react/react@4bc465a16 )**: Rename Controls to PipeableStream ([#24286](react/react#24286)) //<Sebastian Markbåge>//
- **[ece5295](react/react@ece5295e5 )**: Remove unnecessary flag check ([#24284](react/react#24284)) //<zhoulixiang>//
- **[9ededef](react/react@9ededef94 )**: Don't mute hydration errors forcing client render ([#24276](react/react#24276)) //<dan>//
- **[985272e](react/react@985272e26 )**: Fix name mismatch in react-reconciler custom build. ([#24272](react/react#24272)) //<Hikari Hayashi>//
- **[b8cfda1](react/react@b8cfda15e )**: changed Transitions type to Array<Transition> ([#24249](react/react#24249)) //<Luna Ruan>//
- **[c89a15c](react/react@c89a15c71 )**: [ReactDebugTools] wrap uncaught error from rendering user's component ([#24216](react/react#24216)) //<Mengdi "Monday" Chen>//
- **[ebd7ff6](react/react@ebd7ff65b )**: Don't recreate the same fallback on the client if hydrating suspends ([#24236](react/react#24236)) //<dan>//
- **[aa05e73](react/react@aa05e7315 )**: Add 4.4.0 release to eslint rules CHANGELOG ([#24234](react/react#24234)) //<Brian Vaughn>//
- **[7e3121e](react/react@7e3121e1c )**: Remove unstable_createMutableSource from experimental build ([#24209](react/react#24209)) //<Sebastian Silbermann>//
- **[0415b18](react/react@0415b18a1 )**: [ReactDebugTools] add custom error type for future new hooks ([#24168](react/react#24168)) //<Mengdi "Monday" Chen>//

Changelog:
[General][Changed] - React Native sync for revisions 34aa5cf...e8f4a66

jest_e2e[run_all_tests]

Reviewed By: kacieb

Differential Revision: D35581059

fbshipit-source-id: ee031dfc49b1ef663b601f33f3f3f6c5a804971e
rickhanlonii pushed a commit that referenced this pull request Apr 13, 2022
@gaearon @rickhanlonii
Don't recreate the same fallback on the client if hydrating suspends (#…
a96c3fd
…24236)

* Delay showing fallback if hydrating suspends

* Fix up

* Include all non-urgent lanes

* Moar tests

* Add test for transitions
rickhanlonii pushed a commit that referenced this pull request Apr 14, 2022
@gaearon @rickhanlonii
Don't recreate the same fallback on the client if hydrating suspends (#…
77f2031
…24236)

* Delay showing fallback if hydrating suspends

* Fix up

* Include all non-urgent lanes

* Moar tests

* Add test for transitions
rickhanlonii pushed a commit that referenced this pull request Apr 14, 2022
@gaearon @rickhanlonii
Don't recreate the same fallback on the client if hydrating suspends (#…
5527acd
…24236)

* Delay showing fallback if hydrating suspends

* Fix up

* Include all non-urgent lanes

* Moar tests

* Add test for transitions
zhengjitf pushed a commit to zhengjitf/react that referenced this pull request Apr 15, 2022
@gaearon @zhengjitf
Don't recreate the same fallback on the client if hydrating suspends (r…
0a6cd05
…eact#24236)

* Delay showing fallback if hydrating suspends

* Fix up

* Include all non-urgent lanes

* Moar tests

* Add test for transitions
gaearon added a commit to gaearon/react that referenced this pull request Apr 25, 2022
@gaearon
Revert react#24236
ad6b422
@gaearon gaearon mentioned this pull request Apr 25, 2022
Revert #24236 (Don't recreate the same fallback on the client if hydrating suspends) #24434
Merged
gaearon added a commit to gaearon/react that referenced this pull request Apr 25, 2022
@gaearon
Revert react#24236 (Don't recreate the same fallback on the client if…
02e1722
… hydrating suspends)
@gaearon

gaearon commented Apr 25, 2022

Copy link
Copy Markdown
Collaborator Author

I reverted this in #24434.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

gaearon added a commit that referenced this pull request Apr 25, 2022
@gaearon
Revert #24236 (Don't recreate the same fallback on the client if hydr…
bd4784c
…ating suspends) (#24434)

* Revert #24236 (Don't recreate the same fallback on the client if hydrating suspends)

* Use @gate FIXME
Saadnajmi pushed a commit to Saadnajmi/react-native-macos that referenced this pull request Jan 15, 2023
@rickhanlonii @Saadnajmi
React Native sync for revisions 34aa5cf...e8f4a66
399bd1d
Summary:
This sync includes the following changes:
- **[e8f4a66](react/react@e8f4a6653 )**: Fix import in example //<dan>//
- **[bb49abe](react/react@bb49abea2 )**: Update some READMEs ([react#24290](react/react#24290)) //<dan>//
- **[4bc465a](react/react@4bc465a16 )**: Rename Controls to PipeableStream ([react#24286](react/react#24286)) //<Sebastian Markbåge>//
- **[ece5295](react/react@ece5295e5 )**: Remove unnecessary flag check ([react#24284](react/react#24284)) //<zhoulixiang>//
- **[9ededef](react/react@9ededef94 )**: Don't mute hydration errors forcing client render ([react#24276](react/react#24276)) //<dan>//
- **[985272e](react/react@985272e26 )**: Fix name mismatch in react-reconciler custom build. ([react#24272](react/react#24272)) //<Hikari Hayashi>//
- **[b8cfda1](react/react@b8cfda15e )**: changed Transitions type to Array<Transition> ([react#24249](react/react#24249)) //<Luna Ruan>//
- **[c89a15c](react/react@c89a15c71 )**: [ReactDebugTools] wrap uncaught error from rendering user's component ([react#24216](react/react#24216)) //<Mengdi "Monday" Chen>//
- **[ebd7ff6](react/react@ebd7ff65b )**: Don't recreate the same fallback on the client if hydrating suspends ([react#24236](react/react#24236)) //<dan>//
- **[aa05e73](react/react@aa05e7315 )**: Add 4.4.0 release to eslint rules CHANGELOG ([react#24234](react/react#24234)) //<Brian Vaughn>//
- **[7e3121e](react/react@7e3121e1c )**: Remove unstable_createMutableSource from experimental build ([react#24209](react/react#24209)) //<Sebastian Silbermann>//
- **[0415b18](react/react@0415b18a1 )**: [ReactDebugTools] add custom error type for future new hooks ([react#24168](react/react#24168)) //<Mengdi "Monday" Chen>//

Changelog:
[General][Changed] - React Native sync for revisions 34aa5cf...e8f4a66

jest_e2e[run_all_tests]

Reviewed By: kacieb

Differential Revision: D35581059

fbshipit-source-id: ee031dfc49b1ef663b601f33f3f3f6c5a804971e
mrizwanashiq pushed a commit to mrizwanashiq/react that referenced this pull request Jun 25, 2026
@gaearon
Don't recreate the same fallback on the client if hydrating suspends (r…
ffc9fa8
…eact#24236)

* Delay showing fallback if hydrating suspends

* Fix up

* Include all non-urgent lanes

* Moar tests

* Add test for transitions
mrizwanashiq pushed a commit to mrizwanashiq/react that referenced this pull request Jun 25, 2026
@gaearon
Revert react#24236 (Don't recreate the same fallback on the client if…
a717cc3
… hydrating suspends) (react#24434)

* Revert react#24236 (Don't recreate the same fallback on the client if hydrating suspends)

* Use @gate FIXME
hanzo-dev pushed a commit to hanzoai/react that referenced this pull request Sep 9, 2026
@gaearon
Don't recreate the same fallback on the client if hydrating suspends (r…
781a86c
…eact#24236)

* Delay showing fallback if hydrating suspends

* Fix up

* Include all non-urgent lanes

* Moar tests

* Add test for transitions
hanzo-dev pushed a commit to hanzoai/react that referenced this pull request Sep 9, 2026
@gaearon
Revert react#24236 (Don't recreate the same fallback on the client if…
529500d
… hydrating suspends) (react#24434)

* Revert react#24236 (Don't recreate the same fallback on the client if hydrating suspends)

* Use @gate FIXME
@michaltarasiuk michaltarasiuk mentioned this pull request Sep 13, 2026
Bug: Suspense fallback remounts on hydration after use(browser()) + client use(promise) #37620
Open
@yqz314159265-cyber yqz314159265-cyber mentioned this pull request Sep 16, 2026
Hydrate recoverable Suspense fallbacks while browser data is pending #37641
Open
@Jr-kenny Jr-kenny mentioned this pull request Sep 18, 2026
Preserve SSR Suspense fallback when hydration re-suspends on client data #37654
Open
@woahwhattheheck woahwhattheheck mentioned this pull request Oct 2, 2026
Keep the server Suspense fallback when browser-only content suspends on the client #37729
Open
@SmallDevBigNothing SmallDevBigNothing mentioned this pull request Oct 18, 2026
Keep the server fallback mounted when hydration re-suspends #37893
Open
@whitewolfoklahoma-rgb whitewolfoklahoma-rgb mentioned this pull request Oct 21, 2026
Preserve SSR Suspense fallback when a browser-only boundary re-suspends on the client #37948
Open
@superportalmisha superportalmisha mentioned this pull request Oct 27, 2026
Hydrate browser-only Suspense fallbacks after client suspension #38008
Draft
@sameerihs sameerihs mentioned this pull request Nov 8, 2026
Reuse SSR fallback instead of remounting when hydration suspends on client data #37644
Open
@transmogrify-cell transmogrify-cell mentioned this pull request Nov 9, 2026
Keep the server fallback when a client-rendered boundary suspends during hydration #38174
Open
transmogrify-cell added a commit to transmogrify-cell/react that referenced this pull request Nov 10, 2026
@transmogrify-cell
Keep the server fallback when a client-rendered boundary suspends
a4f2462
When the server leaves a boundary in its fallback state (browser(), abort,
or a server error) and the client render suspends on data, React deleted
the server fallback and mounted an identical one, restarting CSS
animations (react#37620).

If the boundary hasn't received new props or a context change, it now
stays dehydrated and keeps the server fallback until the data resolves,
then retries at a normal retry lane. This is scoped to the boundary and
doesn't change when the root commits, unlike react#24236. The server error is
still reported in the same commit as before, and a keptServerFallback
flag prevents reporting it again on retry. A kept boundary checks for
context changes when it bails out, so the fallback still updates when a
context it reads changes. Updates with new props and suspensey resources
recreate the fallback as before.

Re-enable the react#24236 tests that now pass, updated for current error
messages and retry throttling. The transition test stays gated: we don't
hold transitions to keep the server fallback.
@brett0x0 brett0x0 mentioned this pull request Nov 12, 2026
Preserve painted Suspense fallback when hydration suspends #38234
Open
brett0x0 added a commit to brett0x0/react that referenced this pull request Nov 12, 2026
@brett0x0
Preserve painted Suspense fallback when hydration suspends
319b5af
When a boundary's server render failed (or is client-only) and its client
children suspend while hydrating, we used to delete the server rendered
fallback and mount a new one, which restarted CSS animations and threw away
markup that was still correct.

If the server markup for the boundary is the fallback, hydrate it in place
instead: pause hydration while the primary children (which have no server
markup) render, resume it when the fallback begins, and keep the dehydrated
instance around so the cursor can move past the boundary. Nothing is deleted
so the existing DOM nodes are reused.

If the fallback markup doesn't match, the mismatch is recoverable: the
boundary client renders the fallback once and only then gives up on hydration.

Re-enables the three tests that were commented out when the earlier attempt
(react#24236) was reverted for causing late mutations on WWW. Unlike that patch,
this one still commits the fallback in the same render.
@budi92 budi92 mentioned this pull request Nov 28, 2026
[Flight][Fizz] Don't recreate the Suspense fallback if hydration suspends after a server error or browser() bailout #38417
Open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@acdlite acdlite acdlite approved these changes
+1 more reviewer
@sebmarkbage sebmarkbage sebmarkbage approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

CLA Signed React Core Team Opened by a member of the React Core Team

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@gaearon @sizebot @sebmarkbage @acdlite @facebook-github-bot
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.