Repository navigation
fix: avoid sibling-provider context refreshes - #2073
Merged
trueadm merged 1 commit intoOct 15, 2026
Merged
Conversation
domgan-oai
marked this pull request as ready for review
October 15, 2026 00:02
1 task done
8 tasks done
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.
Summary
Changing one provider of a Context currently rerenders consumers beneath a memoized sibling even when their nearest provider's value is unchanged. Keep the existing context-wide invalidation walk, but let direct local reads confirm their actual provider value before rerunning the consumer body.
Fixes #2069.
Object.ison a later version change. Genuine provider changes still update consumers.octanepatch changeset.Validation
pnpm format:check— full hosted check passes; scoped local check also passes for all nine changed files.pnpm typecheck— full hosted check passes; scoped local check also passes for the four changed runtime/test/fixture files.pnpm test— all four hosted runtime shards and their aggregate pass, alongside all React-parity shards, Chromium, package/loader/Astro, website and example coverage.2623e7ab1.pnpm syncandgit diff --checkpass; generation leaves no additional diff.2623e7ab1, in both sibling orders. Real provider updates remain 128/512; visible values and retained hosts are asserted. The new ratio guards run in the existing manual/weekly Bench workflow; ordinary PR CI covers the semantic tests.0/-0case.perf-review: independent read-only review found no remaining must-fix or needs-evidence source findings; mechanical diff scan has zero candidates. Hot paths are direct context recording, provider writes, and memo invalidation (runtime.ts:16654,19124,19142,41022). No DOM, scheduling, compiler-output, runtime-import, or public-export changes. Production Context objects retain one V8 map through local changes and external invalidation followed by the numeric-1fallback; an extra-property negative control changes the map (Node 22.22.3 / V8 12.4). This does not establish all dependency-witness IC behavior or browser latency.concise-code: runtime +70 / −11; one internal read type, one helper and one numeric Context provenance field. Four new files own the semantic fixture/test, render-count benchmark and changeset. Value-only comparison would lose forced external invalidation; a provider subscription index would add unnecessary ownership/lifecycle machinery. The selected-export esbuild probe grows 757 minified bytes; complete production bundle deltas are recorded below.Hosted performance evidence
PR benchmark run 38657660063 passed for head
20ad2a764995eee49fd4124f8a6037097d606977. The measured synthetic merge and landed commit have the same Git tree. All 64 work counters are unchanged; all 20 paired timing operations remain within the report's noise/resolution policy, with no faster/slower verdict.Complete emitted application JavaScript totals (gzip compressed per file and summed):
These are complete application totals, not framework-only portions or initial network transfers. Gzip growth is 51–277 bytes across all 13 scenarios. The public-import context scenario grows 756 raw / 245 gzip bytes. This is the measured byte cost of scoped invalidation, with no regression detected in the measured work/timing suite. The owning provider-scope counts remain separate local/Bench evidence.
Risk / follow-ups
[email protected]registry metadata/minimum-release-age check. Focused validation used the prepared dependency environment with unchanged third-party lock entries; no lockfile or package-admission policy was changed.ea438fb4fc981b34123e579949de4fd6c04f8268while the final PR test shard was running. The close event cancelled that shard (24 jobs had passed, none failed). Merged-commit CI subsequently passed all 27 jobs onea438fb4fc981b34123e579949de4fd6c04f8268; no release or deployment was performed by this task.Provenance
agent-authored)Implementation: Codex task, host
com-79386.Need help on this PR? Tag
@codesmith-botwith what you need.Note
Medium Risk
Touches production memo bailout and context invalidation hot paths; behavior change is scoped but affects all
useContextconsumers behind memo when multiple providers share one context.Overview
Fixes memo bailout incorrectly treating any bump to a shared
Context's$$versionas a direct dependency change, which forced full consumer refreshes when only a sibling provider updated.Direct context reads now record nearest provider + value (with
$$providerVersiontracking local vs external invalidation). Memo invalidation compares the live nearest value withObject.isbefore rerunning consumer bodies; hosted, replayed, default, multi-provider, and externally forced bumps stay conservative.Adds regression coverage (fixture + tests), extends the external-bump epoch test with sibling updates, and wires a provider-scope memo-wall benchmark with ratio guards (0 extra renders at 128/512 consumers when the retained provider is unchanged).
Reviewed by Cursor Bugbot for commit 20ad2a7. Bugbot is set up for automated code reviews on this repo. Configure here.