realtime-js icon indicating copy to clipboard operation
realtime-js copied to clipboard

V2 Realtime error handling

Open EskelCz opened this issue 2 years ago • 2 comments

Improve documentation

Links

https://supabase.com/realtime https://supabase.com/docs/guides/realtime/extensions/postgres-changes

Describe the problem

Haven't found a single mention of error handling. Nothing in google results or github issues either. How should I catch errors? (from exceeding limits for example) Should I just wrap the channel subscription in a try-catch block? Thank you.

EskelCz avatar Mar 23 '23 18:03 EskelCz

+1 to this @RamiroND @soedirgo

kevinco26 avatar Nov 28 '23 02:11 kevinco26

the two places that a channel subscriber can check are upon initial subscription and during an active subscription.

when a channel is attempting to subscribe it can check the status:

...
myChannel.subscribe((status) => {
  console.log(status)
  if (status !== 'SUBSCRIBED') { return }
  ...
})

in order to check if a channel has been rate limited or there was an issue with postgres changes the channel can subscribe to system messages. see https://github.com/supabase/realtime/issues/282#issuecomment-1287221414 and https://supabase.com/docs/guides/realtime/protocol#system-messages for more details.

w3b6x9 avatar Nov 28 '23 19:11 w3b6x9