Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1.0.12: fix(): multi-connection lock blocks reconnect #23

Merged
merged 2 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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