Skip to content

Persisted collection with progressive sync mode wiped on reconnect #1478

@danteissaias

Description

@danteissaias
  • 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions