Dealing with unreliable connections #1102
-
|
(context: TrailBase maintainer here) I was recently thinking a bit more about providing stronger guarantees in the light of "event loss". The TrailBase integration is pretty naive, uses SSE and if it gets auto-reconnected state would likely diverge. To my understanding electric also uses SSE (https://electric-sql.com/docs/api/http#server-sent-events-sse), which is generally pretty opaque when it comes to managing connection state. After taking a quick look at its current implementation, it's not clear to me if there's maybe some magic happening under the hood (e.g. invalidate and re-build state from scratch if sequence numbers get out of sync 🤷♀️). Does electric's integration offer any guarantees? I was mostly wondering what the official stance is for:
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 6 replies
-
|
Friendly ping. Still curious to learn what electric and others do when SSE events get lost. Meanwhile, I've added WebSocket support to TrailBase, which at least let's clients explicitly handle disconnects. Now I'm wondering if there's maybe a way to reset TanStack/DBs internal state machine to "initializaing" (similar to |
Beta Was this translation helpful? Give feedback.
-
|
Friendly ping. @KyleAMathews sorry for the personal nudge, would love to learn how electric thinks about and deals with SSE package loss 🙏 |
Beta Was this translation helpful? Give feedback.
-
|
SSE modes sends regular updates about the latest offset so if the client disconnects for whatever reason, the client knows where they read to and can reconnect at that point. |
Beta Was this translation helpful? Give feedback.
yeah DB has no opinions about how sync happens.
truncateis just for when you need to tell db to delete all data in a collection and restart.