Skip to content
Source
Sign inSign up
TanStack/db

Persisted collection with progressive sync mode wiped on reconnect #1478

Send to my agent
Closeddanteissaias(GitHub profile, opens in a new tab) opened this issue 2 comments
  • I've validated the bug against the latest version of DB packages

Describe the bug

When using electricCollectionOptions with syncMode: "progressive" and persistedCollectionOptions (browser SQLite persistence), data hydrated from persistence gets wiped when the Electric stream reconnects after going offline. The collection drops to 0 items and never recovers.

Persistence and hydration work correctly on their own. The data loads from SQLite after a refresh while offline. The wipe happens the moment the stream comes back online.

To Reproduce

  1. Create a persisted Electric collection with syncMode: "progressive".
  2. Load the page. Data syncs and is persisted to SQLite.
  3. Go offline.
  4. Refresh the page. Data hydrates from SQLite. All rows are visible.
  5. Come back online.
  6. The collection is wiped to 0 items.

Expected behavior

The collection should keep the hydrated rows and resume syncing changes from the stored offset. The stream does resume correctly (the offset and handle are sent in the reconnection request), but the in-memory state is wiped before the stream has a chance to deliver any data.

Desktop

  • OS: macOS
  • Browser: Chromium (Electron)

Additional context

@tanstack/db: 0.6.4
@tanstack/electric-db-collection: 0.3.2
@tanstack/react-db: 0.1.82
@tanstack/browser-db-sqlite-persistence: 0.1.8
@electric-sql/client: 1.5.15
  1. We have observed the same problem and I took liberty to propose a fix which seems to be working for our case. Wonder if you check if it works for yours @danteissaias

  2. we are having the same issue and implemented a workaround as well.

Sign in to join this conversation.