mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-11-27 16:54:04 +00:00
Fixed error handling if client is closed
This commit is contained in:
parent
3c56a6f395
commit
6708eed121
1 changed files with 15 additions and 12 deletions
|
@ -416,11 +416,15 @@ exports.redisPingAsync = function (dsn) {
|
||||||
url: dsn
|
url: dsn
|
||||||
});
|
});
|
||||||
client.on("error", (err) => {
|
client.on("error", (err) => {
|
||||||
if (client.isOpen) client.disconnect();
|
if (client.isOpen) {
|
||||||
|
client.disconnect();
|
||||||
|
}
|
||||||
reject(err);
|
reject(err);
|
||||||
});
|
});
|
||||||
client.connect().then(() => {
|
client.connect().then(() => {
|
||||||
if (client.isOpen) {
|
if (!client.isOpen) {
|
||||||
|
client.emit("error", new Error("connection isn't open"));
|
||||||
|
}
|
||||||
client.ping().then((res, err) => {
|
client.ping().then((res, err) => {
|
||||||
if (client.isOpen) {
|
if (client.isOpen) {
|
||||||
client.disconnect();
|
client.disconnect();
|
||||||
|
@ -430,8 +434,7 @@ exports.redisPingAsync = function (dsn) {
|
||||||
} else {
|
} else {
|
||||||
resolve(res);
|
resolve(res);
|
||||||
}
|
}
|
||||||
}).catch(error => reject);
|
}).catch(error => reject(error));
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue