Skip to content

Commit

Permalink
fix: multiple ws connections due to redundant openConnection calls (#960
Browse files Browse the repository at this point in the history
)
  • Loading branch information
vishalnarkhede authored Apr 22, 2022
1 parent c6c14eb commit 8150199
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,14 @@ export class StreamChat<StreamChatGenerics extends ExtendableGenerics = DefaultG
throw Error('User is not set on client, use client.connectUser or client.connectAnonymousUser instead');
}

if (this.wsConnection?.isConnecting) {
this.logger('info', 'client:openConnection() - connection already in progress', {
tags: ['connection', 'client'],
});

return Promise.resolve();
}

if ((this.wsConnection?.isHealthy || this.wsFallback?.isHealthy()) && this._hasConnectionID()) {
this.logger('info', 'client:openConnection() - openConnection called twice, healthy connection already exists', {
tags: ['connection', 'client'],
Expand Down

0 comments on commit 8150199

Please sign in to comment.