Skip to content

Commit

Permalink
Do not schedule ping timer if the interval and timeout not initialised
Browse files Browse the repository at this point in the history
  • Loading branch information
tjenkinson authored and darrachequesne committed Sep 18, 2024
1 parent 37cbb8d commit da2fa2b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/engine.io-client/lib/socket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,8 @@ export class SocketWithoutUpgrade extends Emitter<
*/
private _resetPingTimeout() {
this.clearTimeoutFn(this._pingTimeoutTimer);
if (this._pingInterval <= 0 || this._pingTimeout <= 0) return;

const delay = this._pingInterval + this._pingTimeout;
this._pingTimeoutTime = Date.now() + delay;
this._pingTimeoutTimer = this.setTimeoutFn(() => {
Expand Down Expand Up @@ -723,7 +725,7 @@ export class SocketWithoutUpgrade extends Emitter<
* @return {boolean}
*/
public isResponsive() {
if (this.readyState === 'closed') return false;
if (this.readyState === "closed") return false;
if (this._pingTimeoutTime === null) return true;

const responsive = Date.now() < this._pingTimeoutTime;
Expand Down

0 comments on commit da2fa2b

Please sign in to comment.