Skip to content

Commit 36d08e2

Browse files
authored
Merge pull request #1508 from input-output-hk/fix/timeout-unref
fix(cardano-services-client): do not call timout id unref in browsers
2 parents 75ded7e + 4be68ab commit 36d08e2

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

packages/cardano-services-client/src/WebSocket.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,8 @@ export class CardanoWsClient extends WsProvider {
400400
if (this.status === 'stop') this.closeResolver();
401401
else {
402402
this.status = 'idle';
403-
setTimeout(() => this.connect(), 1000).unref();
403+
const timeout = setTimeout(() => this.connect(), 1000);
404+
if (typeof timeout.unref === 'function') timeout.unref();
404405
}
405406

406407
this.emitHealth('closed');
@@ -440,7 +441,7 @@ export class CardanoWsClient extends WsProvider {
440441
this.logger.error(error, 'Error while refreshing heartbeat', this.clientId);
441442
}
442443
}, this.heartbeatInterval);
443-
this.heartbeatTimeout.unref();
444+
if (typeof this.heartbeatTimeout.unref === 'function') this.heartbeatTimeout.unref();
444445
}
445446

446447
/** Closes the WebSocket connection. */

0 commit comments

Comments
 (0)