node-redis
node-redis copied to clipboard
Error literal check in RedisClient.prototype.on_ready needs to be wider
Issue
Describe your issue here
Using node-redis with Geode Redis adapter. Server doesn't support INFO command and returns string error message. This error message is not literally the same as the one being checked for in RedisClient.prototype.on_info_cmd error handling code.
The following change will check for both messages, and library works in both standard and Geode cases.
--- a/index.js +++ b/index.js @@ -423,7 +423,7 @@ RedisClient.prototype.on_ready = function () {
RedisClient.prototype.on_info_cmd = function (err, res) { if (err) {
-
if (err.message === "ERR unknown command 'info'") {
-
if (err.message.includes("unknown command")) { this.on_ready(); return; }
Environment
-
Node.js Version:
v11.15.0
-
Redis Version:
Geode Redis Adapter
-
Platform:
Ubuntu 18.04
// Assuming this is part of a larger Redis client implementation
RedisClient.prototype.on_ready = function () {
// Your existing on_ready logic here
};
RedisClient.prototype.on_info_cmd = function (err, res) {
if (err) {
// Handle error for standard Redis
if (err.message === "ERR unknown command 'info'") {
this.on_ready();
return;
}
// Handle error for Geode Redis Adapter
if (err.message.includes("unknown command")) {
this.on_ready();
return;
}
// Handle other errors
console.error('Redis INFO command error:', err);
return;
}
// Handle successful response (if any)
console.log('Redis INFO command response:', res);
};