Skip to content

Commit

Permalink
Merge pull request #23 from tiagosiebler/fixreconn
Browse files Browse the repository at this point in the history
v1.0.12: fix(): multi-connection lock blocks reconnect
  • Loading branch information
tiagosiebler authored Aug 6, 2024
2 parents 567ff0a + 506394c commit 9db5856
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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/*",
Expand Down
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 9db5856

Please sign in to comment.