Repository navigation
fix(data): keep the newest request's value in the shared owner's cache - #2940
Merged
Merged
Conversation
Two tabs sharing an owner could reload the same read and leave the older result saved for the next session: the owner ordered live results by request but kept whichever tab's save arrived last. Each read the owner starts now has a start time later than every read before it, which its reply carries. A replica's value remembers the request that read it, and the owner does not save a value over one a newer request read. Fixes #2934
trueadm
marked this pull request as ready for review
November 15, 2026 21:53
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
octane-website | 168d0d6 | Commit Preview URL Branch Preview URL |
Nov 15 2026, 10:00 PM |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
octane-website-mcp | 168d0d6 | Commit Preview URL Branch Preview URL |
Nov 15 2026, 09:58 PM |
8 of 11 tasks
Contributor
Benchmark report🟢 No byte growth, no added work, and no timing changes beyond ±3%. Compares js-framework: 1k/10k row operationsAll 20 timed operations (20 without a verdict)
All 64 work counters are unchanged. Application bundle size (bytes)No changes across 111 measured values. Public-import reachability bundles (bytes)No changes across 141 measured values. |
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
Why
newest), but persistence had no order: each replica forwards its full value and the owner kept whichever save arrived last.savedAt) cannot stand in for that: tabs stamp one request's value differently (the tab that asked uses its own start, a tab told the value uses the owner's, a write's refreshed value uses its landing time), so ordering by it would drop a tab's later saves for good.Changes
owner.ts: each read the owner starts gets a start time later than every read before it, and its reply carries it (at, as thevaluebroadcast already did).savedrops a value read by an older request than the one last saved for that key; values with no request behind them (seeds, restores, feed values, a write's refreshed reads) are saved as before.store.ts: an entry remembers the owner request that read its value (requestedAt), set by a load from its reply and by a broadcast value, kept across a partial edit, cleared by any other source.Savingcarries it to the owner.docs/data.md: the Cross-tab owner section states the new clause.Validation
pnpm format:check(not run repo-wide;pnpm format:files:checkon every changed file passes)pnpm typecheck(not run repo-wide;pnpm typecheck:fileson the changed files passes)pnpm test(not run locally; left to CI)data-owner.test.ts,data-persist.test.ts,data-store.test.ts,data-feeds.test.ts,data-views.test.tsin--project octane(216 pass), andreact-compat/data.test.tsin--project octane-hosted-react-dev(12 pass).mainall three fail withexpected 'Tides' to be 'Atoll'after the older reply lands; with the fix they pass. The test also pins that the tab left behind saves again once it reloads; breaking the load's request stamp turns it red.perf-review:node scripts/perf-review-scan.mjsreports no candidates. Touched paths run once per network request or per forwarded save, never per render or node: oneWeakMap.getper load, one more field onEntry(set in its single literal) and on theSavingliteral, one number on each read reply. No DOM, scheduling or compiled-output change.concise-code: src +81 −21 (runtime +81 −21); no new files; new exports:requestTimes(store-internal side channel from a replica's reply to its load, called byowner.ts) and theSavingtype's optional field; alternatives: order saves bystored.savedAtin the owner alone (about 8 lines, rejected: tabs stamp one request's value at different times, so a tab's later edits would be dropped whenever another tab stamped later), a per-port "superseded" flag in the owner (rejected: the owner cannot see which values a replica adopted, so the flag has no safe point to clear); bytes: not applicable,octane/dataonly.Risk / follow-ups
Provenance
agent-authored)Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.Note
Medium Risk
Changes shared cross-tab persistence ordering; wrong logic could drop valid saves or leave stale cache entries, though optional protocol fields preserve older builds.
Overview
Fixes a race when multiple tabs share one data owner: if two tabs reload the same read and the older request finishes last, persistence could write that stale value over a newer one, so the next session restored old data while live tabs showed the update.
The owner now stamps each shared read with a monotonic request start time (
aton replies and cross-tabvaluemessages) and tracks newestSaved per cache key. Forwarded save calls from replicas includerequestedAtonSaving; the owner ignores saves from an older request once a newer one's value is already stored. Stores recordrequestedAton entries (viarequestTimeson replies) and pass it through on persist.Docs in the cross-tab owner section describe this rule. Tests run the two-tab reload scenario with a shared encrypted cache and assert offline restore keeps the newer title.
Reviewed by Cursor Bugbot for commit 168d0d6. Bugbot is set up for automated code reviews on this repo. Configure here.