SupabaseS
Supabase7mo ago
Dahaar

Realtime Postgres changes trigger multiple times

The docs show an example for how to set up different callbacks for different tables when setting up realtime postgres events with the Python client.
changes = supabase.channel('db-changes').on_postgres_changes(  
  "*",
  schema="public",
  table="messages"
  callback=lambda payload: print(payload)
).on_postgres_changes(
  "INSERT",
  schema="public",
  table="users",
  callback=lambda payload: print(payload)
).subscribe()


But when changes come in, it actually triggers the callback for the right table multiple times, one time for each other handler that was registered on the channel. So in this example with two handlers, any update on the
messages
table would print the event two times.

Any ideas on how to prevent this or why that could be the case?
Was this page helpful?