docs(rfc): amend context-selector-tearing with Option D (Relay pattern)#36001
Draft
layershifter wants to merge 4 commits intomasterfrom
Draft
docs(rfc): amend context-selector-tearing with Option D (Relay pattern)#36001layershifter wants to merge 4 commits intomasterfrom
layershifter wants to merge 4 commits intomasterfrom
Conversation
The original RFC considered Options A, B, C and selected A (do nothing). Option D was not considered at the time — it emerged from a conversation with the React team after the decision was made. This addendum: - Documents the root cause of the original RFC's "Glitchy Behavior" note: fiber.lanes pollution on the bound-at-mount fiber in dispatchSetStateInternal's eager-bailout check. - Specifies Option D: allow Level 1 tearing, heal in effect via epoch/selector check. Matches Relay's useFragmentInternal pattern. - Compares Option D to Option A across glitch, tearing, concurrent correctness, lint, and API dimensions. - Re-establishes why Options B and C remain inadequate, with new empirical evidence against C (uncommitted-transition value leaks to urgent sibling renders under concurrent mode). - Includes measurements from an investigation probe. Does not modify the original decision record. The addendum is clearly dated and labeled so the history of the prior decision is preserved. Accompanying implementation PR: layershifter/fix-context-selector-bailout.
📊 Bundle size report✅ No changes found |
|
Pull request demo site: URL |
…nk public repro - Drop references to docs/phase-3-root-cause.md, docs/phase-5-comparison.md, and repro/tests/list-probe-cycling.json (private investigation workspace). - Replace with link to public reproduction repo: https://github.com/layershifter/context-selector-bailout-repro - Pin Relay implementation references to commit e3c9d1b5661fb6f58e4d58f81cd930e09a47a89a so links don't move as main progresses.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
docs: amend context-selector-tearing RFC with Option D (Relay pattern)
Summary
Amends
docs/react-v9/contributing/rfcs/react-components/context-selector-tearing.mdwith a new "Addendum" section documenting Option D: a hook rewrite modeled on Relay'suseFragmentInternal.The original RFC considered Options A, B, C and selected A ("do nothing"). Option D was not considered at the time — it emerged from a conversation with the React team after the decision was made. Option D strictly improves on Option A for the "Glitchy Behavior" case without regressing anything else.
Why amend rather than replace
The original decision record is load-bearing context: it documents the reasoning for rejecting Options B and C, the test harness, and the "Level 1 tearing is acceptable" framing. Keeping it intact and appending an addendum preserves that history. The addendum section is clearly dated and labeled as revisiting the decision in light of new evidence and a new option.
What's in the addendum
fiber.lanespollution issue in React'sdispatchSetStateInternaleager-bailout check — the bound-at-mount fiber becomes the stale alternate after the first listener-driven commit and its lanes never get cleared, permanently failing theNoLanesprecondition.react-dom.development.jsthat logsfiber.lanes/alternate.lanesat the check site. First dispatch:fiber=0 alt=0 eager=TRUE. All subsequent dispatches on that fiber:fiber=1 alt=0 eager=FALSE.valueRef.currentduring render (likeuseSyncExternalStore.getSnapshot), no[value, selected]state tuple, nosetState(prev => prev)bailout trick. Listener comparesselector(newValue)against a layout-effect-latchedlastReturnedRef.currentand force-updates only when the slice actually differs. Matches Relay'suseFragmentInternal_CURRENT.jspattern.Accompanying PR
microsoft/fluentui#<TBD>— implementation of Option D in@fluentui/react-context-selector. The two PRs can merge in either order; the doc PR stands on its own as the architectural record.Test plan
Out of scope