-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Closed
Labels
Description
Creating a redis client with legacyMode: true
AND a non-zero pingInterval
leads to a 100% reproducible crash.
Demonstration:
'use strict';
const redis = require('redis');
(async () => {
const clientOptions = {
url: 'redis://:foobar@localhost:6379/',
legacyMode: true,
pingInterval: 3000
};
const redisClient = redis.createClient(clientOptions);
redisClient.on('error', error => {
console.log(`redisClient: error ${error.stack}`);
});
await redisClient.connect();
while (true) {
console.log(new Date().toISOString());
await new Promise(resolve => {
setTimeout(resolve, 1000);
});
}
})();
Output:
2023-01-20T01:27:38.215Z
2023-01-20T01:27:39.216Z
2023-01-20T01:27:40.218Z
.../node_modules/@redis/client/dist/lib/client/index.js:434
.then(reply => this.emit('ping-interval', reply))
^
TypeError: Cannot read properties of undefined (reading 'then')
at Timeout._onTimeout (.../node_modules/@redis/client/dist/lib/client/index.js:434:13)
at listOnTimeout (node:internal/timers:564:17)
at process.processTimers (node:internal/timers:507:7)
Node.js v18.13.0
https://github.com/redis/node-redis/blob/master/packages/client/lib/client/index.ts#L365-L368 seems to assume .ping()
always returns a promise.
Environment:
- Node.js Version: 18.13.0
- Redis Server Version: 7.0.7
- Node Redis Version: 4.5.1
- Platform: Mac OS 13.1 (Intel)
benjie