Skip to content

Commit b01f177

Browse files
committed
ref redis#2524 - clear pingInterval timeout on close
1 parent cf79a80 commit b01f177

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

packages/client/lib/client/index.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,7 @@ export default class RedisClient<
825825
*/
826826
QUIT(): Promise<string> {
827827
return this._socket.quit(async () => {
828+
clearTimeout(this._pingTimer);
828829
const quitPromise = this._queue.addCommand<string>(['QUIT']);
829830
this._tick();
830831
return quitPromise;
@@ -845,6 +846,7 @@ export default class RedisClient<
845846
*/
846847
close() {
847848
return new Promise<void>(resolve => {
849+
clearTimeout(this._pingTimer);
848850
this._socket.close();
849851

850852
if (this._queue.isEmpty()) {
@@ -855,18 +857,19 @@ export default class RedisClient<
855857
const maybeClose = () => {
856858
if (!this._queue.isEmpty()) return;
857859

858-
this._socket.off('data', maybeClose);
860+
this._socket.removeEventListener('data', maybeClose);
859861
this._socket.destroySocket();
860862
resolve();
861863
};
862-
this._socket.on('data', maybeClose);
864+
this._socket.addEventListener('data', maybeClose);
863865
});
864866
}
865867

866868
/**
867869
* Destroy the client. Rejects all commands immediately.
868870
*/
869871
destroy() {
872+
clearTimeout(this._pingTimer);
870873
this._queue.flushAll(new DisconnectsClientError());
871874
this._socket.destroy();
872875
}

0 commit comments

Comments
 (0)