Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .changeset/fix-progressive-mode-fetchsnapshot.md
Original file line number Diff line number Diff line change
@@ -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

**Bug Fixes:**

- Fixed type errors in test files
- All 166 unit tests + 95 E2E tests passing
1 change: 1 addition & 0 deletions packages/db-collection-e2e/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ export { createDeduplicationTestSuite } from "./suites/deduplication.suite"
export { createCollationTestSuite } from "./suites/collation.suite"
export { createMutationsTestSuite } from "./suites/mutations.suite"
export { createLiveUpdatesTestSuite } from "./suites/live-updates.suite"
export { createProgressiveTestSuite } from "./suites/progressive.suite"
Loading
Loading