Sending broadcast events from edge function

I want to send a broadcast event from an edge function but have been unable to do so so far. I'd like to use broadcast instead of listening to postgres changes because I'd like to hide some info from the client.

Using supabase 2.57.4
  • I think. I have this version installed in my client code. I used a starter app for edge functions, and later realized it was using 2.35 in the deno.json file. I updated it and restarted etc but not sure if there's something else I need to do.
Using a local supabase instance with supabase start and supabase functions serve.

I've verified that broadcasting events works between clients. I have two clients and call:
channel.send({ type: 'broadcast', event: 'update', payload: { foo: 'bar' } })
and the other receives it correctly.

In my edge function, I'm not subscribing to the channel. My understanding is that calling channel.send without subscribing will invoke a rest call which is correct.

In my docker logs, it displays the following errors:

"POST /realtime/v1/api/broadcast HTTP/1.1" 500 23 "-" "Deno/2.1.4 (variant; SupabaseEdgeRuntime/1.69.8)"

Ranch listener RealtimeWeb.Endpoint.HTTP, connection process #PID<0.34838.0>, stream 2 had its request process #PID<0.34840.0> exit with reason {{{%MatchError{ term: [""] }, ...

Any ideas? Broadcasting from an edge function is supported right?
Was this page helpful?