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

Delete multi ids subscriptions (Kicked out of supabase realtime)

Open MauruschatM opened this issue 11 months ago • 2 comments

Bug report

  • [X] I confirm this is a bug with Supabase, not with my own application.
  • [X] I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

After some time working in an app, that uses supabase Realtime, supabase seems to clear postgres subscriptions automatically. Therefore, the user doesn't get any updates.

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

Simple Subscription Code snippet for solid-js. (Supabase Auth works in here).

const subscribe = siqn.supabase?.channel(`db-public-calculation_items-${calculationId}`)//.channel(`db-public-calculation_items-${calculation().id}`)
      .on("postgres_changes", {
        event: "*",
        schema: "public",
        table: "calculation_items",
        filter: `calculation_id=eq.${calculationId}`,
      }, (payload: any) => {
        switch (payload.eventType) {
          case "INSERT":
            setCalculationItems(prev => [...prev, mapCalculationItemFromPostgres(payload.new)]);
            updateSum();
            break
          case "UPDATE":
            setCalculationItems(prev => prev.map((item) => item.id === payload.new.id ? mapCalculationItemFromPostgres(payload.new) : item));
            updateSum();
            break
          case "DELETE":
            setCalculationItems(prev => prev.filter(i => i.id !== payload.old.id));
            updateSum();
            break
        }
      })
      .subscribe();

Expected behavior

Why does that happen? Maybe a small disconnect from internet? Or something with the accessToken? Do I have to add manual reconnects to the subsciption?

Screenshots

https://imgur.com/a/qlsnJq0

System information

  • OS: macOS
  • Browser (if applies): Safari
  • Version of supabase-js: 2.46.1
  • Version of Node.js: 18

Additional context

Add any other context about the problem here.

MauruschatM avatar Jan 17 '25 10:01 MauruschatM