From b01f17709fb379dd15fba9bea0fb9b67c59fdd97 Mon Sep 17 00:00:00 2001 From: Leibale Date: Wed, 7 Jun 2023 11:51:49 -0400 Subject: [PATCH] ref #2524 - clear `pingInterval` timeout on close --- packages/client/lib/client/index.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/client/lib/client/index.ts b/packages/client/lib/client/index.ts index 25a0ddf6c4..85dfd9f5e9 100644 --- a/packages/client/lib/client/index.ts +++ b/packages/client/lib/client/index.ts @@ -825,6 +825,7 @@ export default class RedisClient< */ QUIT(): Promise { return this._socket.quit(async () => { + clearTimeout(this._pingTimer); const quitPromise = this._queue.addCommand(['QUIT']); this._tick(); return quitPromise; @@ -845,6 +846,7 @@ export default class RedisClient< */ close() { return new Promise(resolve => { + clearTimeout(this._pingTimer); this._socket.close(); if (this._queue.isEmpty()) { @@ -855,11 +857,11 @@ export default class RedisClient< const maybeClose = () => { if (!this._queue.isEmpty()) return; - this._socket.off('data', maybeClose); + this._socket.removeEventListener('data', maybeClose); this._socket.destroySocket(); resolve(); }; - this._socket.on('data', maybeClose); + this._socket.addEventListener('data', maybeClose); }); } @@ -867,6 +869,7 @@ export default class RedisClient< * Destroy the client. Rejects all commands immediately. */ destroy() { + clearTimeout(this._pingTimer); this._queue.flushAll(new DisconnectsClientError()); this._socket.destroy(); }