supabase / realtime-js

An isomorphic Javascript client for Supabase Realtime server.

Home Page:https://supabase.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

V2 Realtime error handling

EskelCz opened this issue · 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.

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 supabase/realtime#282 (comment) and https://supabase.com/docs/guides/realtime/protocol#system-messages for more details.