Skip to content
Source
Sign inSign up
TanStack/db

fix electric collection progressive mode #852

Mergedsamwillis(GitHub profile, opens in a new tab)merged 7 commits intomain fromrefs/pull/852/headmerged by samwillis(GitHub profile, opens in a new tab)

Showing 10 changed files with 33 additions and 0 deletions (loading 7).

x
0 of 10 viewed, 10 left
32 additions and 0 deletions.changeset/fix-progressive-mode-fetchsnapshot.mdAdded
View file
@@ -0,0 +1,32 @@
+---
+"@tanstack/electric-db-collection": patch
+"@tanstack/db-collection-e2e": patch
+"@tanstack/db": patch
+---
+​
+Fix progressive mode to use fetchSnapshot and atomic swap
+​
+Progressive mode was broken because `requestSnapshot()` injected snapshots into the stream in causally correct position, which didn't work properly with the `full` mode stream. This release fixes progressive mode by:
+​
+**Core Changes:**
+​
+- Use `fetchSnapshot()` during initial sync to fetch and apply snapshots immediately in sync transactions
+- Buffer all stream messages during initial sync (renamed flag to `isBufferingInitialSync`)
+- Perform atomic swap on first `up-to-date`: truncate snapshot data → apply buffered messages → mark ready
+- Track txids/snapshots only after atomic swap (enables correct optimistic transaction confirmation)
+​
+**Test Infrastructure:**
+​
+- Added `ELECTRIC_TEST_HOOKS` symbol for test control (hidden from public API)
+- Added `progressiveTestControl.releaseInitialSync()` to E2E test config for explicit transition control
+- Created comprehensive progressive mode E2E test suite (8 tests):
+ - Explicit snapshot phase and atomic swap validation
+ - Txid tracking behavior (Electric-only)
+ - Multiple concurrent snapshots with deduplication
+ - Incremental updates after swap
+ - Predicate handling and resilience tests