Skip to content

offset=-1 does not return existing data (snapshot) as documented #2995

@schickling

Description

@schickling

Description

ElectricSQL's HTTP API is not returning existing data when requesting with offset=-1, contrary to what the documentation states.

Expected Behavior

According to the Electric documentation:

"When a shape is first requested, Electric queries Postgres for the data and populates the log by turning the query results into insert operations."

When making a GET request to /v1/shape?table=my_table&offset=-1, Electric should:

  1. Query the PostgreSQL table for all existing rows
  2. Convert those rows into insert operations in the shape log
  3. Return them in the response

Actual Behavior

Electric returns an empty array [] despite the table containing data.

Reproduction

I've created a minimal reproduction here: https://github.com/schickling-repros/2025-08-electric-offset-bug

Steps:

  1. Create a table in PostgreSQL with some data
  2. Make a GET request to Electric: /v1/shape?table=test_table&offset=-1
  3. Observe that Electric returns [] instead of the existing data

Evidence

From testing with LiveStore integration:

  • PostgreSQL table contains data (verified by direct query)
  • Electric receives changes via logical replication (seen in logs: "Received transaction 735 (1 changes)")
  • But Electric returns empty array when requesting with offset=-1

Impact

This makes Electric unsuitable for initial client synchronization - it can only sync changes that occur after a client starts listening, not existing data.

Environment

  • ElectricSQL: latest Docker image
  • PostgreSQL: 16-alpine
  • Tested with Node.js client

Related Code

The issue was discovered while implementing a sync provider: https://github.com/livestore/livestore

Is this expected behavior or a bug? If expected, the documentation should be updated to clarify that offset=-1 does not return existing data.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions