mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-12-18 04:04:41 -05:00
Fixed error handling if client is closed
This commit is contained in:
parent
3c56a6f395
commit
6708eed121
@ -416,22 +416,25 @@ 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.ping().then((res, err) => {
|
client.emit("error", new Error("connection isn't open"));
|
||||||
if (client.isOpen) {
|
|
||||||
client.disconnect();
|
|
||||||
}
|
|
||||||
if (err) {
|
|
||||||
reject(err);
|
|
||||||
} else {
|
|
||||||
resolve(res);
|
|
||||||
}
|
|
||||||
}).catch(error => reject);
|
|
||||||
}
|
}
|
||||||
|
client.ping().then((res, err) => {
|
||||||
|
if (client.isOpen) {
|
||||||
|
client.disconnect();
|
||||||
|
}
|
||||||
|
if (err) {
|
||||||
|
reject(err);
|
||||||
|
} else {
|
||||||
|
resolve(res);
|
||||||
|
}
|
||||||
|
}).catch(error => reject(error));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user