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 committed Aug 9, 2024
1 parent 1d5410b commit 999c622
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 @@ -631,6 +631,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 @@ -721,7 +723,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 999c622

Please sign in to comment.