From 4be68abf3ca030d236263a318f067fccd0e44297 Mon Sep 17 00:00:00 2001 From: Daniele Ricci Date: Wed, 9 Oct 2024 12:54:19 +0200 Subject: [PATCH] fix(cardano-services-client): do not call timout id unref in browsers --- packages/cardano-services-client/src/WebSocket.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/cardano-services-client/src/WebSocket.ts b/packages/cardano-services-client/src/WebSocket.ts index 02a03e14a21..22821888d87 100644 --- a/packages/cardano-services-client/src/WebSocket.ts +++ b/packages/cardano-services-client/src/WebSocket.ts @@ -400,7 +400,8 @@ export class CardanoWsClient extends WsProvider { if (this.status === 'stop') this.closeResolver(); else { this.status = 'idle'; - setTimeout(() => this.connect(), 1000).unref(); + const timeout = setTimeout(() => this.connect(), 1000); + if (typeof timeout.unref === 'function') timeout.unref(); } this.emitHealth('closed'); @@ -440,7 +441,7 @@ export class CardanoWsClient extends WsProvider { this.logger.error(error, 'Error while refreshing heartbeat', this.clientId); } }, this.heartbeatInterval); - this.heartbeatTimeout.unref(); + if (typeof this.heartbeatTimeout.unref === 'function') this.heartbeatTimeout.unref(); } /** Closes the WebSocket connection. */