Skip to content

[verified] fix(reconciler): recheck store snapshot after subscribe#36317

Open
soloclz wants to merge 1 commit intofacebook:mainfrom
soloclz:fix/use-sync-external-store-strictmode
Open

[verified] fix(reconciler): recheck store snapshot after subscribe#36317
soloclz wants to merge 1 commit intofacebook:mainfrom
soloclz:fix/use-sync-external-store-strictmode

Conversation

@soloclz
Copy link
Copy Markdown

@soloclz soloclz commented Apr 19, 2026

Summary

  • Problem: useSyncExternalStore can miss a post-subscribe snapshot repair when Suspense + StrictMode remounts a store consumer and the store mutates during subscribe() without notifying listeners.
  • Why it matters: the hook contract expects a snapshot re-check after subscribing, but this remount path skipped that repair step.
  • What changed: subscribeToStore(...) now re-checks the snapshot immediately after subscribe(handleStoreChange) returns and forces a rerender if the store changed during subscribe.
  • What did NOT change (scope boundary): this does not change broader Suspense replay semantics or attempt to guarantee that no stale intermediate render is ever observed before the repair rerender.

How did you test this change?

  • CI=1 npx -y yarn test useSyncExternalStore-test --runInBand
  • CI=1 npx -y yarn test useSyncExternalStore --runInBand

Related to: #35550

@meta-cla meta-cla bot added the CLA Signed label Apr 19, 2026
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.

1 participant