SupabaseS
Supabase2y ago
pida

How to debug "CHANNEL_ERROR" when using supabase-realtime?

Hi,

I'm trying to build an app that needs bidirectionnal connection so I'm using realtime to push data to the app. Basically I have an Electron desktop app that serves as a middleware to a local database and i need to push data to that database. And I need the channel to stay up as long as possible.

When I check the subscription logs, I get this behaviour (picture 1):
channel_error > subscribed > channel_error > subscribed ...

Looking at the source code, I see that subscribe method takes a callback as argument and that callback is given status and error as argument.
So I tried debugging using this small snippet of code:
export const createRealtime = (schemaName: string) => {
  supabase.channel("XXX").on("postgres_changes", { event: "INSERT", schema: schemaName, table: "XXX" }, payload => { console.log(payload) }).subscribe(handleReconnect)
}

const handleReconnect = (event: string, error: Error) => {
  console.log(Date.now(), event, error)
}

As you can see on the screenshot there is no error.

Is there a way to debug this?

Is this normal behaviour to get disconnection if there is no data?

Thanks a lot
image.png
Was this page helpful?