orbitinghail / sqlsync

SQLSync is a collaborative offline-first wrapper around SQLite. It is designed to synchronize web application state between users, devices, and the edge.
https://sqlsync.dev
Apache License 2.0
2.29k stars 30 forks source link

reducer error handling #27

Closed carlsverre closed 10 months ago

carlsverre commented 11 months ago

Currently, if a query fails in the reducer it can leave the reactor in a half-open state. Solutions:

  1. Make error handling the responsibility of the reducer - this is probably the right choice
    • requires updating the guest/host ffi to support returning errors (ideally using result semantics)
    • fbm already supports serializing/deserializing results - so this should be pretty easy
  2. reset the reactor (or entire reducer) on error if we want handle errors in the host
    • the danger here is that user state could also be half-open, so the only safe thing to do is a full reset

Probably 1 is better as it gives the user more flexibility and allows reducers to handle errors. If a reducer doesn't want to do so - it can forward the error to SQLSync, thus also clearing the half-open state.

carlsverre commented 11 months ago

This bug was hit by kakashi443 (discord) and reproduced here: image