Repository navigation
Description
Context
Split out of the core#2050 review (PR #2056, merged). That PR fixed SimplePersistenceCoordinator so a superseded write's promise is properly rejected with OperationCancelledError instead of left unsettled forever. Doing so exposed — and in one case actively worsens — a related, pre-existing gap: the dependency-wait mechanism has no way to distinguish "I was cancelled" from "the write I was waiting on was cancelled or genuinely failed."
Problem
SimplePersistenceCoordinator's dependency-wait loop (runOperation, shared-node-store.svelte.ts around line 222) lets one node's persist operation wait on another's via persistenceDependencies/afterSiblingId (update-protocol.ts:120). Every one of the 5 call sites that .catch()-handles a persist() rejection treats any rejection — including OperationCancelledError — as "expected, ignore it."
This creates a real propagation bug: cancelPending()'s reject can now flow through the dependency-wait loop into an unrelated dependent write, whose .catch then swallows it as an expected cancellation — so the dependent's backend RPC never fires, and nothing surfaces to the user. Before core#2050, cancelPending()'s reject was a no-op (the bug that PR fixed), so this propagation path was latent/inert; it's now live.
More broadly, this was always true one level up: a dependency's promise rejecting for any reason — including a genuine write failure, not just cancellation — has always silently aborted the dependent write via the same swallow-everything .catch pattern. That's a separate, older bug with the same root cause.
Related findings from the same review, filed together since they share the root cause
- Dependency-wait cross-node abort (above) — needs a distinct error type/discriminant threaded through the dependency-wait loop and all 5
.catchsites, so a genuine dependency failure or an unrelated cancellation doesn't silently eat a dependent write. resetInstance()drops unsettled promises without clearing their timers — same defect class as what PersistenceCoordinator leaves superseded write promises unsettled on two of three supersede paths #2050 fixed (cancelPending, the queue-overwrite), but a third, distinct method. No confirmed production call site was found (test setup/teardown only, ~30 files reference it) — lower priority, but the same fix pattern applies if a real path is found.- Duplication, lower priority: the "settle before drop" pattern now appears 3x, and the cancellation-
.catchpattern 5x, across this file. A shared helper would de-duplicate both; disproportionate scope for a targeted bugfix, reasonable for a follow-up refactor.
Suggested approach
For finding 1 (the real bug): give cancellation a distinct, identifiable shape (e.g. a dedicated error class or a discriminant field) so a .catch site can tell "this specific write was cancelled — ignore" apart from "a write I depended on failed or was cancelled — that's not the same thing and may need to propagate or retry." Then update the 5 catch sites to act on that distinction instead of swallowing uniformly.
Acceptance criteria
- A dependent write's outcome is no longer silently determined by an unrelated write's cancellation
- A genuine dependency failure (not just cancellation) is distinguishable at the dependent's catch site from "expected cancellation"
- Regression test: node B depends on node A's write; A's write is cancelled via
cancelPending/supersede; B's write must not silently vanish — either B proceeds independently or B's failure is surfaced, not swallowed -
resetInstance()audited for the same unsettled-promise-plus-live-timer gap ascancelPending/the queue-overwrite; fixed if a real (non-test-only) call path exists - Tests pass (
bun run test:all); code passesbun run quality:fix
Reference
Full analysis in the review discussion on PR #2056 (merged, closes #2050) — the three-way split above (real bug / same-class-lower-priority / refactor) and the specific line numbers cited (runOperation ~line 222, persistenceDependencies in update-protocol.ts:120) came from that review.
Activity
mstomar125 commentedon Aug 14, 2026
Fixed in #2079. Added `DependencyFailedError`, thrown by `runOperation`'s dependency-wait loop instead of letting a dependency's raw rejection (including a propagated `OperationCancelledError`) reach the dependent's own `.catch` site — deliberately not a subclass of `OperationCancelledError`, so it survives the `instanceof` check every one of the 5 catch sites uses to decide "expected cancellation, ignore" vs "genuine failure, surface it."
Audited all 5 sites: `updateNode()`, `setNode()`, and `persistBatchedChanges()` already surfaced non-cancellation failures correctly and needed no changes. `deleteNode()`'s catch site was silently swallowing every non-cancellation error (not just propagated dependency failures) — fixed to match the established write-failure notification pattern, since it's also the site most directly exposed (real dependencies, used to avoid FK violations on delete). `updateTaskNode()` never declares dependencies, so it isn't exposed to this specific bug; its separate silent-swallow gap is a different bug class, left out of scope.
Also audited `resetInstance()` per the acceptance criteria's conditional — confirmed no production call path exists (every call site is test setup/teardown across ~30 files), documented the finding, no functional change needed.
Regression test reproduces the concrete sequence (node A's write cancelled before it fires, node B depends on A) both at the coordinator level directly and end-to-end through `SharedNodeStore.updateNode()`'s `persistenceDependencies` — verified to fail against the pre-fix code (B's write silently vanished, no notification) before the fix, and pass after.
The third related finding from the original review (de-duplicating the "settle before drop" and cancellation-`.catch` patterns that now appear repeatedly across this file) is explicitly noted in the issue itself as disproportionate scope for a targeted bugfix — left as a candidate for a future refactor, not filed as a new issue since the original issue already documents it.