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:
- Query the PostgreSQL table for all existing rows
- Convert those rows into insert operations in the shape log
- 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:
- Create a table in PostgreSQL with some data
- Make a GET request to Electric:
/v1/shape?table=test_table&offset=-1
- 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.
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 making a GET request to
/v1/shape?table=my_table&offset=-1, Electric should: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:
/v1/shape?table=test_table&offset=-1[]instead of the existing dataEvidence
From testing with LiveStore integration:
offset=-1Impact
This makes Electric unsuitable for initial client synchronization - it can only sync changes that occur after a client starts listening, not existing data.
Environment
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=-1does not return existing data.