Skip to content

Commit

Permalink
Merge pull request #1508 from input-output-hk/fix/timeout-unref
Browse files Browse the repository at this point in the history
fix(cardano-services-client): do not call timout id unref in browsers
  • Loading branch information
iccicci authored Oct 9, 2024
2 parents 75ded7e + 4be68ab commit 36d08e2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/cardano-services-client/src/WebSocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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. */
Expand Down

0 comments on commit 36d08e2

Please sign in to comment.