Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What is the meaning of "Channel names must be unique when using multiple subscription hooks"? #397

Open
jameshfisher opened this issue Mar 4, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@jameshfisher
Copy link

On this page I read:

NOTE: Channel names must be unique when using multiple subscription hooks.

What does "uniqueness" mean here? Some possible interpretations:

  • It's an error for my code to have two useSubscription call sites using the same channel name
  • It's an error for a client to call useSubscription twice using the same channel name
  • It's an error for two separate clients to try to subscribe using the same channel name

I don't know how to interpret this advice, because I have no mental model of how channel names are used in this Postgres changes system, and haven't been able to find any model in the Supabase docs. (I've asked about this on their Discord support.)

Whatever the meaning is, what is the consequence of not using unique channel names? What bad things can happen?

Thanks again for this library! <3

@jameshfisher jameshfisher added the bug Something isn't working label Mar 4, 2024
@jameshfisher
Copy link
Author

Or - what if I just use Math.random().toString() in my channel name, so it's unique every time the hook is called?

@psteinroe
Copy link
Owner

psteinroe commented Mar 4, 2024

hey! thanks for the kind words.

I don't know how to interpret this advice, because I have no mental model of how channel names are used in this Postgres
changes system, and haven't been able to find any model in the Supabase docs. (I've asked about this on their Discord support.)

I actually also do not know exactly how the channel names work. I used this with both a static string, e.g. conversations when subscribing the conversation table, and one that includes the table and the filter, e.g. conversations:inbox-${inboxId}. Both work fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants