Skip to content
Source
Sign inSign up
TanStack/db

Persistence mode: a failed local insert's row remains in live syncedData until restart #2071

Send to my agent
ClosedCyberistic(GitHub profile, opens in a new tab) opened this issue 1 comment

After upgrading from 0.9 to 0.12 we pinned the following behavior in our bridge tests (@tanstack/db 0.12.1 + @tanstack/db-sqlite-persistence-core 0.4.5). We could not remediate it from supported APIs, so we are reporting it rather than working around it further.

Repro shape

  1. persistedCollectionOptions(...) over createSQLiteCorePersistenceAdapter (sync-present mode).
  2. collection.insert(row) where the mutation's outbound ship rejects (a refused save).
  3. The transaction fails; tx.state === "failed".

Observed

  • The persisted store is correct: the failed row never reaches SQLite (applyCommittedTx never sees it). A restart rebuilds without the row. ✔
  • The LIVE collection keeps the row in syncedData indefinitely: 0.12 appears to fold a failed optimistic insert into the synced data (the optimistic overlay no longer outlives the transaction), and post-failure sync-channel writes targeting the key are silently not applied (no error; the transaction applies to the persistence adapter but not to the in-memory store — we observed a delete reach applyCommittedTx while syncedData kept the row).
  • The same flow WITHOUT the persistence wrapper rolls back live state correctly, so this is persistence-mode-specific.

Expected

A failed mutation's effect should not persist in the live collection any more than it persists in the store — either the optimistic insert should stay overlay-only until acked, or post-failure channel writes should reconcile the in-memory store the way they reach the adapter.

Context

Our bridge previously relied on completed-transaction overlays surviving persistence (0.9 behavior) and now acks mutations through the sync channel on success only. The residual gap is purely this: failed writes linger visibly until restart in persistence-mode collections.

  1. my idiot clanker opened this without asking I apologize so much probably a real problem though

Sign in to join this conversation.