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

Flush subscriptions on logout #33

Open
moizhusnain opened this issue Jul 14, 2022 · 0 comments
Open

Flush subscriptions on logout #33

moizhusnain opened this issue Jul 14, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@moizhusnain
Copy link
Member

When we logout with SDK, the project object never really gets destroyed. It can be reused again, particularly in case of browsers. This is where we are encountering an error with subscriptions.

Senario

Developer subscribed to a topic (as a part of app logic). Then logged out and logged back in. The app logic will kick in again and we will try to subscribe to the topic again. The callback will getting stacked, but SDK isn't sending sub packet to server.

This is happening because the project object was reused. We were already subscribed to the topic, the older callback was stacked and as per the logic of SDK, we don't send another sub packet to server if it was subscribed before (we just stack the second callback and relay event to both callbacks whenever we get an update). But now in our case, because of the logout, the topic was automatically unsubscribed on server. But to SDK, the topic was subscribed (since there is already a callback on the topic).

This issue can be easily fixed by simply flushing the event handlers on logout event (when connection gets closed).

@moizhusnain moizhusnain added the bug Something isn't working label Jul 14, 2022
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

1 participant