Skip to content

Conversation

@eps1lon
Copy link
Collaborator

@eps1lon eps1lon commented Sep 5, 2025

Fixes a bug that was encountered at Meta when empty roots were mounted. We accidentally attributed empty roots to hydrated Suspense Components and expected an Offscreen Fiber.

While fixing this I noticed that we're also accidentally considering host roots as timed out (their state is always non-nullable) and therefore didn't measure them on mount. Not measuring the root means their children may not be aligned properly depending on the implementation for painting the rects.

I included rects of the root in the snapshot serializer to make the issue more obvious. The PR is split into previous and fixed behavior to make the change more obvious.

@meta-cla meta-cla bot added the CLA Signed label Sep 5, 2025
@github-actions github-actions bot added the React Core Team Opened by a member of the React Core Team label Sep 5, 2025
Comment on lines -3713 to -3715
throw new Error(
'There should always be an Offscreen Fiber child in a hydrated Suspense boundary.',
);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We were in the host root branch here. We're forking earlier now and only enter this branch for <Suspense>

// This Suspense Fiber is still dehydrated. It won't have any children
// until hydration.
}
const isTimedOut = fiber.memoizedState !== null;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was always true for host roots since their state is non-nullable. We now unconditionally measure host roots.

@eps1lon eps1lon force-pushed the sebbie/mount-suspense-root-fixes branch 2 times, most recently from 8203421 to c486bc8 Compare September 5, 2025 21:00
@eps1lon eps1lon marked this pull request as ready for review September 5, 2025 21:01
@eps1lon eps1lon merged commit 8943025 into facebook:main Sep 8, 2025
480 checks passed
@eps1lon eps1lon deleted the sebbie/mount-suspense-root-fixes branch September 22, 2025 17:11
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.

2 participants