-
-
Notifications
You must be signed in to change notification settings - Fork 599
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
LiveQuerySubscription "open" event does not fire as expected #1147
Comments
You brought up an interesting point. The point of waiting for the subscription is to ensure the connection is successful, resulting in the open event to not fire. We should remove it from the documentation. @acinader @davimacedo Thoughts? |
@travsr Can you post your quick fix? I'm curious on how you got it to work. |
@dplewis what do you want to remove from the docs? The open event? |
@davimacedo Hmm we could add a slight delay here. This will allow client time to set an Open Event and possibly the same for Error event. |
Yes. Just |
@dplewis @davimacedo Yep that's exactly where I added it in my code as well :) I used 200 ms and it hasn't given me issues so far. |
Closes: #1147 Waits 200 milliseconds to allow for client to set open event after the subscription resolves.
* Fix: Live Query Subscription Open Event Closes: #1147 Waits 200 milliseconds to allow for client to set open event after the subscription resolves. * fix tests
Issue Description
When I register an
open
event for aLiveQuerySubscription
, the event does not fire on the intial websocketsubscribed
event as you'd expect. However, if it does fire if a reconnect happens.My guess is the fact that you now have to wait for the subscription object to be returned via promise from
query.subscribe()
may be the cause. By the time you are able to register your event, the "open" event will already have been emitted byLiveQueryClient
.My quick fix was to add a slight timeout delay before the
open
event is emitted inLiveQueryClient.js
, but that seems like more of a hack than a real solution.Maybe I was just doing something wrong but this seemed like something potentially worth posting here.
Test Case
To accurately reproduce your issue. Add your test cases here and read the Contributing Guide to run the tests.
Environment Setup
Server
JS SDK
Logs/Trace
The text was updated successfully, but these errors were encountered: