realtime
realtime copied to clipboard
Return an error when subscribing to a table that _does not_ have realtime on.
Feature request
Problem
I was trying to use realtime on my app. I was not receiving updates from my table. I later figured out that realtime was disabled. There was no error when subscribing; thus, I didn't think right away that realtime was disabled on my table.
Solution
Realtime should throw an error when a client tries to listen on a table that does not have realtime activated.
Alternatives
Developers might also be able to implement this feature in supabase-js
@clouedoc Right now, Realtime server allows clients to connect and gives flexibility to the developer to turn on and off Realtime for specific tables or all tables at will but I can definitely empathize with the problem you described above.
I think what you're asking for is pretty straightforward when it comes to listening to a table (e.g. public:table) but what about listening to all changes (*) or listening to all changes in a schema (e.g. public:*)? Do you expect to receive errors if there's not at least one table with Realtime enabled in those scenarios?
@w3b6x9 I have to admit that I didn't even consider this kind of scenario 😅
IMO, the best-effort solution is to throw if no selected table has real-time enabled.
e.g. if the user is trying to listen for all changes, but no table has realtime enabled, Realtime would throw an error e.g. if the user listens for a schema, if no table of specific schema has realtime enabled, Realtime would throw on error e.g. if the user listens to all tables, and at least one table is enabled, Realtime would not throw
Related: https://github.com/supabase/realtime/issues/247
FYI this is happening in a larger effort currently to surface to clients what's happening on the backend.
More updates soon.
You'll now get system message like:
{
"channel":"any",
"extension":"postgres_changes",
"message":"Subscribing to PostgreSQL failed: {:error, {:subscription_insert_failed, %{\"event\" => \"*\", \"schema\" => \"public\", \"table\" => \"blah\"}}}",
"status":"error"
}
It's a response in the socket, but you'll also see it in your Realtime logs. It would be nice to return a specific message about the table not existing. We have an internal task to do more checks on subscribe so we can return more specific error messages.