Skip to content

A throwing transform drops changes from sql.subscribe() #24

Closed

Description

@okomarov

sql.subscribe() decodes replication rows with the pool's transform (for example transform.row.from). If a transform throws, the error goes through errored() on the replication connection: it logs "Unexpected error during logical streaming - reconnecting", reconnects on a new slot, and the changes in flight are lost.

Reproduced during the #13 review: with a throwing transform.row.from, both inserted rows were lost, including one inserted 300 ms after the throw.

For a query, a throwing transform is that query's own error and rejecting it is right. A subscription has no query to reject, so the throw should not reach the stream. Options: guard the decode per change and rethrow as an uncaught exception, as #13 does for subscribe callbacks; or deliver the error to the subscription's onerror.

Activity

  1. okomarov commented on Oct 11, 2026

    @okomarov
    Author

    Decided for 4.4.0:

    • A transform that throws while a change is decoded skips that change; the replication stream keeps going (no reconnect, nothing else lost).
    • The error goes only to the subscribers that would have received the change: matched by command and table. Subscriptions filtered by key (=id) get it for their table, since the key comes from the transformed row.
    • Per subscriber: its onerror is called if it passed one; if any matching subscriber has no onerror, the error is rethrown once as an uncaught exception, as [FIXED in 4.4.0] A throwing user callback breaks connection state #13 does for callbacks.
    • onerror stays attached across reconnects (today it is bound to the stream that existed at subscribe time).
    • Document onerror (connection errors and changes that could not be decoded; the change is skipped and the subscription continues).
    • Behaviour change: a subscriber without onerror used to get a console message and a reconnect; its process can now exit on the uncaught exception.
  2. added a commit that references this issue on Oct 11, 2026
  3. moved this to Shipped in Roadmapon Oct 15, 2026
  4. added
    area: listen-subscribe
    bug
    on Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: listen-subscribebug

    Type

    No type

    Projects

    • Status
      Shipped

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions