Skip to content

Commit

Permalink
fix(): multi-connection lock blocks reconnect
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagosiebler committed Aug 6, 2024
1 parent 567ff0a commit 7e8e7d0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/lib/BaseWSClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,9 @@ export abstract class BaseWebsocketClient<
return { wsKey };
}

if (this.wsStore.isConnectionAttemptInProgress(wsKey)) {
if (
this.wsStore.isConnectionState(wsKey, WsConnectionStateEnum.CONNECTING)
) {
this.logger.error(
'Refused to connect to ws, connection attempt already active',
{ ...WS_LOGGER_CATEGORY, wsKey },
Expand Down Expand Up @@ -468,6 +470,7 @@ export abstract class BaseWebsocketClient<

private reconnectWithDelay(wsKey: TWSKey, connectionDelayMs: number) {
this.clearTimers(wsKey);

if (!this.wsStore.isConnectionAttemptInProgress(wsKey)) {
this.setWsState(wsKey, WsConnectionStateEnum.RECONNECTING);
}
Expand Down
1 change: 1 addition & 0 deletions src/lib/websocket/WsStore.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export enum WsConnectionStateEnum {
CONNECTED = 2,
CLOSING = 3,
RECONNECTING = 4,
// ERROR_RECONNECTING = 5,
// ERROR = 5,
}

Expand Down

0 comments on commit 7e8e7d0

Please sign in to comment.