Repository navigation
Description
Found while working on #2057 (fixed in #2079) — confirmed real and reproducible, but unrelated to that issue's dependency-wait-cancellation scope, so filing separately rather than folding in.
The bug
Several PersistenceCoordinator.persist() closures in shared-node-store.svelte.ts (updateNode(), setNode(), and — before #2079's fix — deleteNode()) follow this pattern:
} catch (dbError) {
const error = dbError instanceof Error ? dbError : new Error(String(dbError));
const occError = isVersionConflict(dbError) ? dbError : null; // checks the ORIGINAL dbError
if (occError) {
// ...own rollback + a specific conflict notification (version-mismatch), synchronously...
}
throw error; // re-throws `error`, NOT `dbError`
}The real command errors crossing the Tauri/gRPC boundary (VERSION_CONFLICT, SUBTREE_ACCESS_DENIED, etc. — see isVersionConflict's and isSubtreeAccessDenied's own doc comments/type guards in packages/desktop-app/src/lib/types/errors.ts) are plain objects ({ code, conflictData, ... }), not instanceof Error. So error = dbError instanceof Error ? dbError : new Error(String(dbError)) wraps them in a brand-new generic Error — losing the .code/.conflictData shape entirely — before re-throwing.
The OUTER handle.promise.catch((err) => { if (isVersionConflict(err)) return; ...surface a generic write-failure notification... }) then checks isVersionConflict(err) on this already-stripped err — which can never match, since it's a plain Error with no .code property. The guard silently fails, and the outer catch proceeds to add a SECOND, generic write-failure notification on top of the specific one the inner closure already raised.
Confirmed reproduction
An OCC conflict on updateNode() (fallback path, no current_node embedded in the daemon's response) currently produces BOTH:
{ conflictType: 'version-mismatch', message: 'Your edit conflicted with a remote change' }(correct, from the inner closure){ conflictType: 'write-failure', message: "Your change couldn't be saved..." }(spurious duplicate, from the outer catch's guard silently failing to match)
Reproduced with a throwaway test mocking backendAdapter.updateNode to reject with a plain-object VERSION_CONFLICT error (matching the shape real daemon errors use, and the shape every existing OCC test in this file already mocks with, e.g. ai-chat-occ-conflict-regression.test.ts's makeVersionConflictError).
setNode()'s equivalent OCC handling (same error/dbError pattern, same outer-catch guard shape) is presumed to have the identical bug — not independently reproduced with a test, but the code shape is identical.
Why #2079 didn't need to fix this generally
#2079 hit this same underlying issue while fixing deleteNode()'s catch site (adding a guard against a NEW class of bug — silently swallowing genuine deletion failures — required distinguishing "this was a subtree-access-denied refusal, already notified" from "a genuine other failure," and the naive isSubtreeAccessDenied(err) check hit exactly this stripping bug). It was fixed there via a captured boolean flag (subtreeAccessDeniedAlreadyNotified, set inside the closure before the flag is available) rather than re-deriving from the outer catch's err. That fix is scoped to deleteNode() only.
updateNode()'s and setNode()'s pre-existing instances of this same double-notification bug are untouched — fixing them is a distinct concern from #2057's dependency-wait-cancellation scope.
Suggested fix
Same pattern as #2079's deleteNode() fix: capture a boolean (or the already-classified occError) in the closure's outer scope before the throw, and have the handle.promise.catch(...) check that captured value instead of re-deriving from the re-thrown err. Alternatively (broader, more invasive): stop discarding the original error's shape in the error = dbError instanceof Error ? dbError : new Error(...) conversion — e.g. preserve dbError's properties via Object.assign or a custom wrapper, so downstream instanceof/shape checks on the re-thrown value keep working. The narrower per-closure captured-flag fix is lower risk and matches the precedent #2079 already set.
Scope
packages/desktop-app/src/lib/services/shared-node-store.svelte.ts: updateNode()'s and setNode()'s OCC-conflict catch handling (each has its own handle.promise.catch(...) — 2 of the 5 sites enumerated in #2057). Not urgent (the user sees an accurate specific message alongside a redundant generic one, not a wrong or missing message), but worth cleaning up.
Activity
mstomar125 commentedon Aug 14, 2026
Fixed in #2091 — mirrors #2079's captured-boolean-flag pattern exactly for `updateNode()`'s confirmed duplicate.
Investigated `setNode()`'s presumed identical bug before applying the same fix there, and confirmed empirically (via a probe test, before writing the real fix) that it does NOT reproduce: `setNode()`'s persist closure has no OCC-specific notification of its own to duplicate against, so an OCC failure there already correctly surfaces exactly one (generic) notification today. The dead `isVersionConflict(err)` check in its outer catch was removed as misleading dead code rather than "fixed" with an unnecessary flag. See the PR for the full investigation and regression tests covering both methods.