-
Notifications
You must be signed in to change notification settings - Fork 57
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
When using useChannel
channel never detaches even when all listeners have unsubscribed
#1594
Comments
➤ Automation for Jira commented: The link to the corresponding Jira issue is https://ably.atlassian.net/browse/SDK-4054 |
Hello @thenano ! Thank you for bringing this up. The issue here is that, as you've correctly noticed, This is a bug and will be fixed. I'll let you know when we've released a fix. |
Thanks very much for the reply @VeskeR |
Hey @VeskeR , I think I ran into the same issue. I was using the imperative API previously and was manually detaching the channels.
I traced it back to the same line of code. Let me know if there's anyway I can help debug the issue more or patch it on my end first. Version that I'm on: |
Bumping this issue again as we are facing the same issues as @zameschua |
It looks like the detach on this line never runs, because
channel.listeners.length
always evaluates as 1.Please forgive me if my investigation is way off and I have looked in the wrong place. From what I could tell,
listeners
in theChannel
is actually a function, defined byEventEmitter
, which would return any listeners when called without and event, or the event specific listeners when called with an event.Apart from that, it looks like the channel's subscriptions are actually held in the channel's
subscriptions
attribute, which is also an instance ofEventEmitter
, so this would be the right place to look for remaining subscriptions?It looks to me that to ensure there are no more listeners in the channel and we can safely detach, one would have to check all any/events/anyOnce/eventsOnce subscriptions? Something like:
or some sort of
!some
loop on all subscriptions?Happy to do a pull request is any of this makes sense? Apologies if I'm doing something wrong.
┆Issue is synchronized with this Jira Bug by Unito
The text was updated successfully, but these errors were encountered: