electric-sql / electric

Sync little subsets of your Postgres data into local apps and services.
https://electric-sql.com
Apache License 2.0
6.48k stars 156 forks source link

fix: Handle 400 errors as unrecoverable #1880

Closed msfstef closed 1 month ago

msfstef commented 1 month ago

Fixes https://github.com/electric-sql/electric/issues/1876

The issue was that we were sending must-refetch messages with some of our 400s, although they were unrecoverable and re-fetching would trigger an infinite loop.

I've made the server send 400 errors for the cases where the shape_id and shape_definition do not match, with an explanatory message, and I've made the client terminate when receiving such an error.

As a temporary measure, the error is not thrown into the ether but stored in the ShapeStream (accessible via stream.error).

We have had some discussions with @balegas about making errors more "handleable" by changing our approach to the ShapeStream instantiation. I think this warrants opening a new issue and corresponding PR to discuss more thoroughly.