Skip to content

Commit

Permalink
perf(cluster): use timer.refresh()
Browse files Browse the repository at this point in the history
  • Loading branch information
darrachequesne committed Feb 20, 2024
1 parent f09a1c3 commit d782d96
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions lib/cluster-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -719,13 +719,14 @@ export abstract class ClusterAdapterWithHeartbeat extends ClusterAdapter {

private scheduleHeartbeat() {
if (this.heartbeatTimer) {
clearTimeout(this.heartbeatTimer);
this.heartbeatTimer.refresh();
} else {
this.heartbeatTimer = setTimeout(() => {
this.publish({
type: MessageType.HEARTBEAT,
});
}, this._opts.heartbeatInterval);
}
this.heartbeatTimer = setTimeout(() => {
this.publish({
type: MessageType.HEARTBEAT,
});
}, this._opts.heartbeatInterval);
}

override close() {
Expand Down

0 comments on commit d782d96

Please sign in to comment.