Skip to content

fix: use private Realtime channel for .stream()#1324

Open
jeremiahseun wants to merge 2 commits intosupabase:mainfrom
jeremiahseun:fix-private-only-stream-channel-10188984025532099214
Open

fix: use private Realtime channel for .stream()#1324
jeremiahseun wants to merge 2 commits intosupabase:mainfrom
jeremiahseun:fix-private-only-stream-channel-10188984025532099214

Conversation

@jeremiahseun
Copy link
Copy Markdown

What kind of change does this PR introduce?

Bug fix.

What is the current behavior?

When public channels are disabled in a Supabase project ("Allow public access to channels" is false), attempting to use .stream() results in an Exception: "PrivateOnly: This project only allows private channels". This happens because .stream() creates a Realtime channel without specifying it as private. By explicitly configuring the RealtimeChannelConfig with private: true, .stream() bypasses this restriction and instead relies on Row Level Security (RLS) policies, effectively allowing users to track Postgres changes on tables with private realtime channel settings.

What is the new behavior?

Fixes an issue where supabase.from('table').stream(...) throws a RealtimeSubscribeException ("PrivateOnly: This project only allows private channels") when the "Allow public access to channels" setting is disabled in the Supabase project.

This changes _realtimeClient.channel(...) inside SupabaseStreamBuilder to use RealtimeChannelConfig(private: true), ensuring the stream function respects table RLS policies and successfully connects even if public channels are disabled.

Additional context

This resolves #1311

When public channels are disabled in a Supabase project ("Allow public access to channels" is false), attempting to use `.stream()` results in an Exception: "PrivateOnly: This project only allows private channels". This happens because `.stream()` creates a Realtime channel without specifying it as private. By explicitly configuring the `RealtimeChannelConfig` with `private: true`, `.stream()` bypasses this restriction and instead relies on Row Level Security (RLS) policies, effectively allowing users to track Postgres changes on tables with private realtime channel settings.
When public channels are disabled in a Supabase project ("Allow public access to channels" is false), attempting to use `.stream()` results in an Exception: "PrivateOnly: This project only allows private channels". This happens because `.stream()` creates a Realtime channel without specifying it as private. By explicitly configuring the `RealtimeChannelConfig` with `private: true`, `.stream()` bypasses this restriction and instead relies on Row Level Security (RLS) policies, effectively allowing users to track Postgres changes on tables with private realtime channel settings.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Using stream convenience function doesn't work with private-only realtime channels setting.

1 participant