Skip to content

Commit 8061f52

Browse files
committed
feat(connection): Do unlock check earlier after connect.
1 parent 0d2e5fe commit 8061f52

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

modules/xmpp/XmppConnection.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,8 +402,15 @@ export default class XmppConnection extends Listenable {
402402

403403
// after connecting - immediately check whether shard changed,
404404
// we need this only when using websockets as bosh checks headers from every response
405-
if (this._usesWebsocket && this._oneSuccessfulConnect) {
406-
this._keepAliveAndCheckShard();
405+
if (this._usesWebsocket) {
406+
if (this._oneSuccessfulConnect) {
407+
// on reconnect we do it immediately
408+
this._keepAliveAndCheckShard();
409+
} else {
410+
// delay it a bit to not interfere with the connection process
411+
// and to allow backend to correct any possible split brain issues
412+
setTimeout(() => this._keepAliveAndCheckShard(), 5000);
413+
}
407414
}
408415
this._oneSuccessfulConnect = true;
409416

0 commit comments

Comments
 (0)