Repository navigation
feat(data): settle writes in flight when the data worker crashed - #2625
Merged
Merged
Conversation
trueadm
marked this pull request as ready for review
November 13, 2026 21:48
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
settleor the page reloaded. The plan's crash section says a reconnected tab settles it by asking the owner, without resending.Changes
owner.ts, replica:live, the replica calls the store's internalresettle();receipt: true, recognised by the journal's receipt name);ask.owner.ts, owner:recover.store.ts:recover(receipt,settleByReceipt) and reused byresettle();unjournalis called only for durable writes.persist.ts:unjournalof an id this persistence never saw finds the entry by its hashed name, so it removes an entry an earlier owner journaled.dataWorkerhelper gainscrash(), which detaches DevTools first. Otherwise Chrome holds the restarted same-name shared worker until a debugger resumes it.docs/data.md, websitedata.mdx(the "Current limits" section is replaced by "Writes in flight when the worker crashes"),llms.txtand the plan doc. Also correctsdocs/data.md, which still gave the protocol version as 3.octane. No PROTOCOL bump: older tabs and workers ignore or omit the new flag, and the journal filter is owner-side only.Validation
data-persist,data-owner,data-storeand the other data suites, react-compat/react-hosted data,--project octane --project octane-prod: 20 files, 478 tests (before the merge);data-persist+data-ownerre-run after merging main: 188 passed.resettle→ both crash cases fail;unjournal→ the receipt is looked up again after a restart.resettle, the crash test fails.pnpm typecheck:fileson changed files,pnpm format:files:check,pnpm synccleanpnpm test,pnpm typecheck, full Shelf suite: left to CIperf-review:node scripts/perf-review-scan.mjs→ no candidates. Not a runtime hot path: the new work runs once per reconnect (resettle), once per receipt lookup, and as one string comparison per replica request.concise-code: src +99 −47. No new files or exports.resettleis the only new internal; it reuses the receipt settlement thatrecoveralready did, and the replica's two request senders now share oneask.journal.receipt.octane/dataentry (esbuild minify, devalue external) goes from 50,690 to 51,217 raw (+527) and from 19,648 to 19,849 gzip (+201).Risk / follow-ups
Provenance
agent-authored)Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.Note
Medium Risk
Touches cross-tab crash recovery, journal ownership, and shared receipt caching; wrong behavior could double-send writes or disagree across tabs, though the change is narrow and heavily tested.
Overview
Journaled writes that were in flight when the shared data worker crashes now settle automatically after tabs reconnect: each tab looks up the write’s receipt (confirm or rollback) without resending the write. The owner deduplicates receipt reads so every tab gets the same answer from one server lookup.
On the owner, receipt requests are flagged and cached (up to 256); journal
recoveromits writes still journaled on the current worker so a later tab does not steal another tab’s in-flight write. On replicas, reconnecting after a crash triggersresettle()once the account is live again.persist.unjournalcan remove journal entries written by a previous owner after a crash.storesharessettleByReceiptbetween startup recovery andresettle, and onlyunjournals durable writes.Shelf e2e simulates a crash mid-reply and asserts both tabs confirm with a single write on the wire; docs and the cross-tab plan mark phase 5b done (protocol 4 in docs).
Reviewed by Cursor Bugbot for commit 1713bd5. Bugbot is set up for automated code reviews on this repo. Configure here.