From 7e8e7d0b00a248aac2a3945a0a0f8414fb644e50 Mon Sep 17 00:00:00 2001 From: Tiago Siebler Date: Tue, 6 Aug 2024 11:06:07 +0100 Subject: [PATCH 1/2] fix(): multi-connection lock blocks reconnect --- src/lib/BaseWSClient.ts | 5 ++++- src/lib/websocket/WsStore.types.ts | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lib/BaseWSClient.ts b/src/lib/BaseWSClient.ts index 236c6ea..3efa84e 100644 --- a/src/lib/BaseWSClient.ts +++ b/src/lib/BaseWSClient.ts @@ -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 }, @@ -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); } diff --git a/src/lib/websocket/WsStore.types.ts b/src/lib/websocket/WsStore.types.ts index c48d22b..280129f 100644 --- a/src/lib/websocket/WsStore.types.ts +++ b/src/lib/websocket/WsStore.types.ts @@ -6,6 +6,7 @@ export enum WsConnectionStateEnum { CONNECTED = 2, CLOSING = 3, RECONNECTING = 4, + // ERROR_RECONNECTING = 5, // ERROR = 5, } From 506394c689b18ae55d31710277fff533236c38c3 Mon Sep 17 00:00:00 2001 From: Tiago Siebler Date: Tue, 6 Aug 2024 11:17:24 +0100 Subject: [PATCH 2/2] v1.0.12: fix() connection duplication lock prevented reconnection workflow --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index f288f6f..fc1010b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "gateio-api", - "version": "1.0.11", + "version": "1.0.12", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "gateio-api", - "version": "1.0.11", + "version": "1.0.12", "license": "MIT", "dependencies": { "axios": "^1.6.6", diff --git a/package.json b/package.json index 09ebb33..0036a3e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gateio-api", - "version": "1.0.11", + "version": "1.0.12", "description": "Complete & robust Node.js SDK for Gate.io's REST APIs, WebSockets & WebSocket APIs, with TypeScript declarations.", "scripts": { "clean": "rm -rf dist/*",