From f0975cd929ead07dee2cb5cbed5faa0eebe75b0f Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Sat, 18 Nov 2023 01:17:54 +0800 Subject: [PATCH] Should be a final ulitmate fix for request timeout issue (#4045) * Try to fix timeout again * Ops --- db/patch-timeout.sql | 7 +++++++ server/database.js | 1 + server/model/monitor.js | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 db/patch-timeout.sql diff --git a/db/patch-timeout.sql b/db/patch-timeout.sql new file mode 100644 index 000000000..f25711201 --- /dev/null +++ b/db/patch-timeout.sql @@ -0,0 +1,7 @@ +-- You should not modify if this have pushed to Github, unless it does serious wrong with the db. +BEGIN TRANSACTION; + +UPDATE monitor SET timeout = (interval * 0.8) +WHERE timeout IS NULL OR timeout <= 0; + +COMMIT; diff --git a/server/database.js b/server/database.js index 29ab3b941..07a43a812 100644 --- a/server/database.js +++ b/server/database.js @@ -83,6 +83,7 @@ class Database { "patch-add-gamedig-given-port.sql": true, "patch-notification-config.sql": true, "patch-fix-kafka-producer-booleans.sql": true, + "patch-timeout.sql": true, }; /** diff --git a/server/model/monitor.js b/server/model/monitor.js index 54a1972c4..194980a12 100644 --- a/server/model/monitor.js +++ b/server/model/monitor.js @@ -369,7 +369,7 @@ class Monitor extends BeanModel { // Runtime patch timeout if it is 0 // See https://github.com/louislam/uptime-kuma/pull/3961#issuecomment-1804149144 - if (this.timeout <= 0) { + if (!this.timeout || this.timeout <= 0) { this.timeout = this.interval * 1000 * 0.8; }