Skip to content

[Fiber] Propagate context to dehydrated Suspense boundaries before bailout (#36594)#36595

Open
denk0403 wants to merge 1 commit into
facebook:mainfrom
denk0403:36594-fix
Open

[Fiber] Propagate context to dehydrated Suspense boundaries before bailout (#36594)#36595
denk0403 wants to merge 1 commit into
facebook:mainfrom
denk0403:36594-fix

Conversation

@denk0403
Copy link
Copy Markdown
Contributor

@denk0403 denk0403 commented Jun 2, 2026

Summary

Fixes #36594.

Motivation: When streaming SSR hydrates a Suspense boundary, a context update in an already-hydrated ancestor (e.g. a provider useState update with stable children) can land before the streamed segment hydrates. React bailed out early on the dehydrated boundary without recording that context change, so the client later hydrated server HTML against the new context value and reported a hydration mismatch.

Fix: Before early-bailing on a dehydrated Suspense boundary, call lazilyPropagateParentContextChanges; if a parent context changed, route through updateSuspenseComponent instead of skipping propagation so childLanes is updated and updateDehydratedSuspenseComponent can recover cleanly.

How did you test this change?

A Fizz regression test covers the scenario: context updates in the hydrated shell before the streamed boundary resolves, with no mismatch error and the boundary showing the updated value.

image

Visual Test

No hydration error!

Screen.Recording.2026-06-02.at.12.26.54.AM.cropped.mp4

@meta-cla meta-cla Bot added the CLA Signed label Jun 2, 2026
@react-sizebot
Copy link
Copy Markdown

Comparing: 557e28f...729c496

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 = 6.84 kB 6.84 kB +0.05% 1.88 kB 1.88 kB
oss-stable/react-dom/cjs/react-dom-client.production.js +0.05% 614.26 kB 614.56 kB +0.02% 108.57 kB 108.59 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 6.84 kB 6.84 kB = 1.88 kB 1.88 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js +0.04% 680.19 kB 680.49 kB +0.03% 119.51 kB 119.54 kB
facebook-www/ReactDOM-prod.classic.js +0.04% 700.61 kB 700.91 kB +0.02% 123.09 kB 123.12 kB
facebook-www/ReactDOM-prod.modern.js +0.04% 690.93 kB 691.23 kB +0.03% 121.48 kB 121.51 kB

Significant size changes

Includes any change greater than 0.2%:

(No significant changes)

Generated by 🚫 dangerJS against 729c496

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: Context updates cause hydration errors when consumers are streamed

2 participants