mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-11-23 23:04:04 +00:00
Should be an ulitmate fix for request timeout issue (#4011)
This commit is contained in:
parent
0608881954
commit
6e80c850f4
2 changed files with 11 additions and 1 deletions
|
@ -367,6 +367,12 @@ class Monitor extends BeanModel {
|
||||||
bean.duration = 0;
|
bean.duration = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Runtime patch timeout if it is 0
|
||||||
|
// See https://github.com/louislam/uptime-kuma/pull/3961#issuecomment-1804149144
|
||||||
|
if (this.timeout <= 0) {
|
||||||
|
this.timeout = this.interval * 1000 * 0.8;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (await Monitor.isUnderMaintenance(this.id)) {
|
if (await Monitor.isUnderMaintenance(this.id)) {
|
||||||
bean.msg = "Monitor under maintenance";
|
bean.msg = "Monitor under maintenance";
|
||||||
|
|
|
@ -1132,13 +1132,17 @@ if (process.env.TEST_BACKEND) {
|
||||||
*/
|
*/
|
||||||
module.exports.axiosAbortSignal = (timeoutMs) => {
|
module.exports.axiosAbortSignal = (timeoutMs) => {
|
||||||
try {
|
try {
|
||||||
|
// Just in case, as 0 timeout here will cause the request to be aborted immediately
|
||||||
|
if (!timeoutMs || timeoutMs <= 0) {
|
||||||
|
timeoutMs = 5000;
|
||||||
|
}
|
||||||
return AbortSignal.timeout(timeoutMs);
|
return AbortSignal.timeout(timeoutMs);
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
// v16-: AbortSignal.timeout is not supported
|
// v16-: AbortSignal.timeout is not supported
|
||||||
try {
|
try {
|
||||||
const abortController = new AbortController();
|
const abortController = new AbortController();
|
||||||
|
|
||||||
setTimeout(() => abortController.abort(), timeoutMs || 0);
|
setTimeout(() => abortController.abort(), timeoutMs);
|
||||||
|
|
||||||
return abortController.signal;
|
return abortController.signal;
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
|
|
Loading…
Reference in a new issue