Persistence mode: a failed local insert's row remains in live syncedData until restart #2071
Send to my agentAfter 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#
persistedCollectionOptions(...)overcreateSQLiteCorePersistenceAdapter(sync-present mode).collection.insert(row)where the mutation's outbound ship rejects (a refused save).- The transaction fails;
tx.state === "failed".
Observed#
- The persisted store is correct: the failed row never reaches SQLite (
applyCommittedTxnever sees it). A restart rebuilds without the row. ✔ - The LIVE collection keeps the row in
syncedDataindefinitely: 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 reachapplyCommittedTxwhilesyncedDatakept 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.
Cyberistic(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
my idiot clanker opened this without asking I apologize so much probably a real problem though