-
-
Notifications
You must be signed in to change notification settings - Fork 390
Description
Bug report
- I confirm this is a bug with Supabase, not with my own application.
- I confirm I have searched the Docs, GitHub Discussions, and Discord.
Describe the bug
Hi, the issue my project is facing is that in the local dev env the Realtime database broadcast works as expected, but in the remote env my app does not receive any updates despite successful subscription.
Logs from the app:
- 21:52:31.501 INFO realtime onOpen event
- 21:52:31.906 INFO realtime onMessage with {ref: 1, event: phx_reply, payload: {status: ok, response: {postgres_changes: []}}, topic: realtime:realtime_event_1}
- 21:52:31.907 INFO got key=realtime_event_1, status=RealtimeSubscribeStatus.subscribed
realtime logs from dashboard.json
Related notes:
- I see the entry as expected in realtime.messages table
- Realtime Inspector just shows errors in local dev and remote, but that's from postgres_changes, don't see anything for broadcast.
- The realtime.messages table shows "realtime off" button in both envs, doesn't seem to be an issue based on local dev env.
- The app uses Google social auth.
What I've tried already in the remote env:
- Disable RLS / private mode
- Init Supabase instance using the service role key instead of anon key
- Migrating JWT in settings from legacy to modern
- Double checked realtime key on subscription/publication
- Full restart of the database
I've also created a similar Supabase support ticket, but my project is currently on the free tier and not sure when they will get a chance to check. Wanted to check if other users had a similar issue and add more context.
Thanks.
To Reproduce
Set RLS policy on realtime.messages:
alter policy "realtime messages policy"
on "realtime"."messages"
to authenticated
using (
true
);
Subscribe to realtime stream from app:
final channel = services.supabase.client
.channel('realtime_key_1', opts: const RealtimeChannelConfig(private: true))
.onBroadcast(
event: 'realtime_event_1',
callback: (msg) async {
try {
log.info('broadcast for key=$key, got msg=$msg');
await _onBroadcast(msg);
} on Exception catch (err) {
log.error('for key=$key, got err=$err');
}
},
)
.subscribe((status, error) => _onSubscribeStatus(key, status, error));
Send realtime broadcast from database rpc:
PERFORM realtime.send(v_event, 'realtime_event_1', 'realtime_key_1', true);
Expected behavior
Realtime broadcast from database should reach the app in remote env as it does in local dev env.
Screenshots
There is a difference in the database publication setup. In local dev, one table is selected, while in the remote env no tables are selected. Clicking into either, I don't see an option to add the realtime.messages table. The local dev setup does not show any table enabled either, must be some default table being enabled and hidden?
The local dev env contains a _realtime schema which was not created in the remote env. Possibly it's required for realtime subscriptions.
System information
- OS: Release build running on Windows / Android
- Version of Flutter: 3.32.7, Dart: 3.8.1, supabase_flutter: 2.9.1
Fix
Investigating the screenshots further, the fix was to add the missing publication via alter publication supabase_realtime_messages_publication add table realtime.messages
. Odd because I did not have to add this line in the local dev env, seems Supabase automatically handled it there but not in the remote env.
Team, a lot of time was unnecessarily wasted on this issue. From what I can tell, this was an infrastructure issue rather than an app logic issue. Please investigate the following:
- Why wasn't the publication automatically created in the remote env?
- Why doesn't Realtime Inspector show updates on the broadcast extension?
- Why is the _realtime table created in the local dev environment, but not the remote env environment? Doesn't seem to cause any harm but the discrepancy makes me feel uneasy.