Skip to content

[Reconciler] Preserve the portal container when replaying a mount - #38391

Open
omerfarukgurbuz wants to merge 1 commit into
react:mainfrom
omerfarukgurbuz:fix/portal-container-on-replay
Open

omerfarukgurbuz wants to merge 1 commit into
react:mainfrom
omerfarukgurbuz:fix/portal-container-on-replay

Conversation

@omerfarukgurbuz

Copy link
Copy Markdown

Summary

Fixes #38389. A portal fiber gets its host container when it is created. If the portal's own child suspends during a transition, React can replay the mounting fiber. Resetting its state node at that point loses the container before the portal can push it again.

Keep the portal state node across the mount reset. The regression test resolves a context consumer as the portal child and checks both where it renders and what a sibling outside two nested providers reads.

How did you test this change?

On GitHub Codespaces, the new test failed against 92bb0678c5 with a null containerInfo read and unexpected context pops. With the fix:

  • yarn test ReactDOMFiber-test --runInBand and its --prod variant each passed all 38 tests.
  • yarn test --maxWorkers=2 --testTimeout=30000 passed all 324 suites (6,828 passed, 23 skipped). On the first full run a React Flight garbage-collection test reached Jest's five-second timeout. It passed in isolation at the original timeout before the full rerun.
  • yarn test --prod --maxWorkers=2 --testTimeout=30000 passed all 324 suites (6,813 passed, 22 skipped).
  • yarn prettier-check all and yarn lint passed.
  • yarn flow dom-node reported no errors.

@meta-cla meta-cla Bot added the CLA Signed label Nov 25, 2026
@github-actions

Copy link
Copy Markdown

A size report will appear here when the build finishes.

Generated by sizebot against 553d246

@omerfarukgurbuz

Copy link
Copy Markdown
Author

Could someone from the React team approve the CI workflows when they have a chance? Thanks!

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

1 participant