-
Notifications
You must be signed in to change notification settings - Fork 80
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
CRNS-264: Connection related fixes/changes #626
Conversation
Size Change: +2.35 kB (1%) Total Size: 216 kB
|
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.
LGTM
@@ -492,6 +491,8 @@ export class StableWSConnection< | |||
return; | |||
} else { | |||
this.resolvePromise?.(event); | |||
// set healthy.. | |||
this._setHealth(true); |
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.
this should fix the bug "watch or presence requires an active WebSocket connection"
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.
LGTM
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.
LGTM
…at-js into vishal/sethealth-fix
17c9c02
@AnatolyRugalev @ferhatelmas @thesyncim Updated some aliases after discussion with @mahboubii :
|
src/client.ts
Outdated
if (this.wsConnection) { | ||
return this.wsConnection.disconnect(timeout); | ||
} | ||
this.disconnectUser(timeout); |
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.
this needs to be run on the function entry point before we reset the activeChannels state
this.disconnectUser(timeout); | |
const returnPromise = this.disconnectUser(timeout); | |
..... | |
cleanup client | |
... | |
return returnPromise; |
Ok so finalising following endpoints as per discussion:
Will add these changes tomorrow !! |
client._setupConnection -> client.openConnection client.wsConnection.disconnect -> client.closeConnection client.connectUser -> client.connectUser client.disconnect -> client.disconnectUser
…at-js into vishal/sethealth-fix
src/client.ts
Outdated
}; | ||
|
||
/** | ||
* Reconnects the current user. |
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.
* Reconnects the current user. | |
* Creates a new WebSocket connection with the current user. throws if there is an active connection |
c399521
to
9163e77
Compare
9163e77
to
5c5e352
Compare
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.
LGTM 🌮
Submit a pull request
setHealth(true)
only after you receive first ws event (so moved fromonopen
toonmessage
). Only afteronmessage
, we can be sure that connection is ready. This is mentioned in one of the existing code comments as well:Introducing this change, because we don't get
connectionId
fromonopen
callback on websocket. We only getconnectionId from
onmessage
callback. So with existing implementation, if you want to rewatch/requery channels uponnetwork recovery, you can't rely on health of websocket to do that. Because watching channels requires connectionId.
After the change, you can easily do following:
Introduced two aliases
client.closeConnection
forclient.wsConnection.disconnect
// Updated descriptionclient.openConnection
forclient._setupConnection
// Updated descriptionThis makes it easier for push notification handling - as mentioned in caveats
Removed
client.connectionId
to avoid hassle of keeping it in sync withclient.wsConnection.connectionId
. Lets only access it fromclient.wsConnection.connectionId
moving forwardTODO
CLA
Description of the pull request