electric-sql / electric-sql/pglite

`pglite-sync` saves incorrect `offset` for shapes returning more than one chunk

Open
#509 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
16k
Forks
442
Avg merge
20h 19m
Merged PRs (30d)
7

Description

(+ some discussion on discord).

According to @thruflo , "The electric-offset header "Must be used as the value of the offset parameter in your next request."
https://electric-sql.com/openapi.html#/paths/~1v1~1shape/get". `pglite-sync` currently uses `messageAggregator[messageAggregator.length - 1].offset` https://github.com/electric-sql/pglite/blob/6b60fbc55c2d59eb7642d1d3f560999ec5b4ec40/packages/pglite-sync/src/index.ts#L252

As all operation-level `offset`s appear to be the same, regardless of what is returned by the `electric-offset` header, that means `pglite-sync` will save the incorrect `offset` for any shape that returns more than one chunk initially.

What appears needs doing is to keep the last valid `Offset` returned by `stream.lastOffset` (so ignore `0_inf`), which you can get at the moment you receive the last chunk.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.