Skip to content

Commit acb3e4f

Browse files
authored
fix electric collection progressive mode (#852)
* fix electric colleciton progressive mode * improve progressive e2e tests * add txid tracking tests * changeset * format * bump electric client version * address review
1 parent e1b6d54 commit acb3e4f

File tree

10 files changed

+1225
-143
lines changed

10 files changed

+1225
-143
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
"@tanstack/electric-db-collection": patch
3+
"@tanstack/db-collection-e2e": patch
4+
"@tanstack/db": patch
5+
---
6+
7+
Fix progressive mode to use fetchSnapshot and atomic swap
8+
9+
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:
10+
11+
**Core Changes:**
12+
13+
- Use `fetchSnapshot()` during initial sync to fetch and apply snapshots immediately in sync transactions
14+
- Buffer all stream messages during initial sync (renamed flag to `isBufferingInitialSync`)
15+
- Perform atomic swap on first `up-to-date`: truncate snapshot data → apply buffered messages → mark ready
16+
- Track txids/snapshots only after atomic swap (enables correct optimistic transaction confirmation)
17+
18+
**Test Infrastructure:**
19+
20+
- Added `ELECTRIC_TEST_HOOKS` symbol for test control (hidden from public API)
21+
- Added `progressiveTestControl.releaseInitialSync()` to E2E test config for explicit transition control
22+
- Created comprehensive progressive mode E2E test suite (8 tests):
23+
- Explicit snapshot phase and atomic swap validation
24+
- Txid tracking behavior (Electric-only)
25+
- Multiple concurrent snapshots with deduplication
26+
- Incremental updates after swap
27+
- Predicate handling and resilience tests
28+
29+
**Bug Fixes:**
30+
31+
- Fixed type errors in test files
32+
- All 166 unit tests + 95 E2E tests passing

packages/db-collection-e2e/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@ export { createDeduplicationTestSuite } from "./suites/deduplication.suite"
2525
export { createCollationTestSuite } from "./suites/collation.suite"
2626
export { createMutationsTestSuite } from "./suites/mutations.suite"
2727
export { createLiveUpdatesTestSuite } from "./suites/live-updates.suite"
28+
export { createProgressiveTestSuite } from "./suites/progressive.suite"

0 commit comments

Comments
 (0)