Skip to content

Commit

Permalink
Nullcheck ping_interval and timeout_timer uses
Browse files Browse the repository at this point in the history
  • Loading branch information
anoek committed Oct 21, 2023
1 parent 4c853b1 commit c861d03
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/GobanSocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@ export class GobanSocket<
this.latency = latency;
this.clock_drift = drift;
this.emit("latency", latency, drift);
clearTimeout(this.timeout_timer);
if (this.timeout_timer) {
clearTimeout(this.timeout_timer);
}
///console.log("Pong:", this.url);
});
}
Expand Down Expand Up @@ -173,7 +175,9 @@ export class GobanSocket<
this.options.ping_interval &&
this.options.ping_interval !== this.current_ping_interval
) {
clearInterval(this.ping_timer);
if (this.ping_timer) {
clearInterval(this.ping_timer);
}
this.ping_timer = niceInterval(
this.ping,
this.options.ping_interval || DEFAULT_PING_INTERVAL,
Expand Down

0 comments on commit c861d03

Please sign in to comment.