-
-
Notifications
You must be signed in to change notification settings - Fork 32
Resolve race condition by ensuring that op=connected
has been received before sending a new subscribe event
#48
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #48 +/- ##
============================================
+ Coverage 67.13% 68.11% +0.98%
- Complexity 78 82 +4
============================================
Files 11 11
Lines 359 367 +8
Branches 24 24
============================================
+ Hits 241 250 +9
+ Misses 104 103 -1
Partials 14 14
Continue to review full report at Codecov.
|
@@ -88,7 +89,8 @@ private static URI getDefaultUri() { | |||
Subscription<T> subscription = new Subscription<>(requestId, query); | |||
subscriptions.append(requestId, subscription); | |||
|
|||
if (inAnyState(WebSocketClient.State.CONNECTED)) { | |||
// TODO: differentiate between state=CONNECTED, vs received op=connected response |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whoops, this should have been removed
before sending a new subscribe event. Fixes parse-community#46
@rogerhu @mmimeault ping? We'd like to get this merged to at least get a SNAPSHOT built in order to fix the bug in our app. |
Nice find and thanks for the test. |
Can we please get a new release or snapshot built to include these changes? We're working towards a push of a release on our Android platform very soon. |
We have auto snapshots via Sonatype here: https://oss.sonatype.org/content/repositories/snapshots/com/parse/parse-livequery-android/1.0.3-SNAPSHOT/ I can push a release though. |
release works if thats easy enough. thanks. |
@rogerhu was the release published? we're not seeing it available on sonatype yet. |
It's on jCenter (point your Gradle config to jcenter() instead of mavenCentral()) already. Getting Bintray to approve auto-syncing to Sonatype. |
ParseLiveQueryClient.subscribe()
checks if the socket state is "CONNECTED" before sending the subscribe event. If it's not, it triggers a reconnect.The problem is that when the socket connects, we also send the
op=connect
event to the server, and wait for the server to respond withop=connected
. At the time ofop=connected
, we then send any pending subscribe messages.If a subscribe request comes in after the socket is connected, but before the
op=connected
message comes from the server, we will end up with that subscription duplicated, and we'll receive duplicated events as a result.