From 58b6ae83579aaf6a2a4e450f3de4515ecf0f810f Mon Sep 17 00:00:00 2001 From: keyvan Date: Wed, 15 Jan 2025 10:56:25 -0800 Subject: [PATCH] fix(pyth-lazer-sdk): clear timeout on shutdown --- lazer/sdk/js/package.json | 2 +- lazer/sdk/js/src/socket/websocket-pool.ts | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lazer/sdk/js/package.json b/lazer/sdk/js/package.json index 95e5a906d..4f0707e60 100644 --- a/lazer/sdk/js/package.json +++ b/lazer/sdk/js/package.json @@ -1,6 +1,6 @@ { "name": "@pythnetwork/pyth-lazer-sdk", - "version": "0.3.0", + "version": "0.3.1", "description": "Pyth Lazer SDK", "publishConfig": { "access": "public" diff --git a/lazer/sdk/js/src/socket/websocket-pool.ts b/lazer/sdk/js/src/socket/websocket-pool.ts index 3ee44ba15..c756efc09 100644 --- a/lazer/sdk/js/src/socket/websocket-pool.ts +++ b/lazer/sdk/js/src/socket/websocket-pool.ts @@ -14,6 +14,7 @@ export class WebSocketPool { private messageListeners: ((event: WebSocket.Data) => void)[]; private allConnectionsDownListeners: (() => void)[]; private wasAllDown = true; + private checkConnectionStatesInterval: NodeJS.Timeout; private constructor(private readonly logger: Logger = dummyLogger) { this.rwsPool = []; @@ -23,7 +24,7 @@ export class WebSocketPool { this.allConnectionsDownListeners = []; // Start monitoring connection states - setInterval(() => { + this.checkConnectionStatesInterval = setInterval(() => { this.checkConnectionStates(); }, 100); } @@ -218,5 +219,6 @@ export class WebSocketPool { this.subscriptions.clear(); this.messageListeners = []; this.allConnectionsDownListeners = []; + clearInterval(this.checkConnectionStatesInterval); } }