Skip to content
Source
Sign inSign up
TanStack/db

fix(electric-db-collection): preserve persisted rows on progressive resume #1493

Mergedpkudinov(GitHub profile, opens in a new tab)merged 5 commits intomain fromrefs/pull/1493/headmerged by KyleAMathews(GitHub profile, opens in a new tab)

Showing 3 changed files with 126 additions and 10 deletions.

x
0 of 3 viewed, 3 left
5 additions and 0 deletions.changeset/progressive-persisted-resume.mdAdded
View file
@@ -0,0 +1,5 @@
+---
+'@tanstack/electric-db-collection': patch
+---
+​
+Prevent progressive Electric collections from truncating persisted rows when resuming from saved Electric shape metadata.
5 additions and 1 deletionpackages/electric-db-collection/src/electric.tsModified
View file
@@ -1441,7 +1441,11 @@
let transactionStarted = false
const newTxids = new Set<Txid>()
const newSnapshots: Array<PostgresSnapshot> = []
- let hasReceivedUpToDate = false // Track if we've completed initial sync in progressive mode
+ // Track if we've completed initial sync in progressive mode. A persisted
+ // resume starts from an already-committed stream offset, so the next
+ // up-to-date message must not run the initial atomic swap again.
+ let hasReceivedUpToDate =
+ syncMode === `progressive` && canUsePersistedResume
// Progressive mode state
// Helper to determine if we're buffering the initial sync
116 additions and 9 deletionspackages/electric-db-collection/tests/electric.test.tsModified
View file