Fixed error handling if client is closed

This commit is contained in:
Kenneth Foster 2023-06-14 11:49:33 -04:00
parent 3c56a6f395
commit 6708eed121

View File

@ -416,11 +416,15 @@ exports.redisPingAsync = function (dsn) {
url: dsn
});
client.on("error", (err) => {
if (client.isOpen) client.disconnect();
if (client.isOpen) {
client.disconnect();
}
reject(err);
});
client.connect().then(() => {
if (client.isOpen) {
if (!client.isOpen) {
client.emit("error", new Error("connection isn't open"));
}
client.ping().then((res, err) => {
if (client.isOpen) {
client.disconnect();
@ -430,8 +434,7 @@ exports.redisPingAsync = function (dsn) {
} else {
resolve(res);
}
}).catch(error => reject);
}
}).catch(error => reject(error));
});
});
};