You've already forked node-redis
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:
@@ -341,6 +341,19 @@ describe('Client', () => {
|
|||||||
legacyMode: true
|
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', () => {
|
describe('events', () => {
|
||||||
|
@@ -362,7 +362,8 @@ export default class RedisClient<
|
|||||||
this.#pingTimer = setTimeout(() => {
|
this.#pingTimer = setTimeout(() => {
|
||||||
if (!this.#socket.isReady) return;
|
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))
|
.then(reply => this.emit('ping-interval', reply))
|
||||||
.catch(err => this.emit('error', err))
|
.catch(err => this.emit('error', err))
|
||||||
.finally(() => this.#setPingTimer());
|
.finally(() => this.#setPingTimer());
|
||||||
|
Reference in New Issue
Block a user