1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-06 02:15:48 +03:00

Fix legacyMode/pingInterval issue (#2386)

* Add a test for legacyMode pingInterval

* Apply patch to fix legacy mode ping interval

* use this.#sendCommand instead of this.#v4

Co-authored-by: Leibale <me@leibale.com>
This commit is contained in:
Benjie
2023-01-25 01:11:48 +00:00
committed by GitHub
parent 85bf97bb39
commit 2287efdd1e
2 changed files with 15 additions and 1 deletions

View File

@@ -341,6 +341,19 @@ describe('Client', () => {
legacyMode: true
}
});
testUtils.testWithClient('pingInterval', async client => {
assert.deepEqual(
await once(client, 'ping-interval'),
['PONG']
);
}, {
...GLOBAL.SERVERS.OPEN,
clientOptions: {
legacyMode: true,
pingInterval: 1
}
});
});
describe('events', () => {

View File

@@ -362,7 +362,8 @@ export default class RedisClient<
this.#pingTimer = setTimeout(() => {
if (!this.#socket.isReady) return;
(this as unknown as RedisClientType<M, F, S>).ping()
// using #sendCommand to support legacy mode
this.#sendCommand(['PING'])
.then(reply => this.emit('ping-interval', reply))
.catch(err => this.emit('error', err))
.finally(() => this.#setPingTimer());