From 735180e8e38c06a7a43e9cf4032d4e1307d4aaf8 Mon Sep 17 00:00:00 2001 From: Ian Macabulos Date: Sun, 18 Jan 2026 09:33:30 +0800 Subject: [PATCH] fix: handle upside-down mode in retry reset logic --- server/model/monitor.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/server/model/monitor.js b/server/model/monitor.js index 5c57d58ca..a1cc3251d 100644 --- a/server/model/monitor.js +++ b/server/model/monitor.js @@ -447,13 +447,19 @@ class Monitor extends BeanModel { if (!previousBeat || this.type === "push") { previousBeat = await R.findOne("heartbeat", " monitor_id = ? ORDER BY time DESC", [this.id]); + if (previousBeat) { retries = previousBeat.retries; - // If the monitor is currently UP, the retry counter must be reset to 0. - // This prevents carrying over old retry counts if the push handler didn't reset them. - if (previousBeat.status === UP) { - retries = 0; + // We must check if the monitor is Upside Down (where UP=Bad, DOWN=Good) + if (this.upsideDown) { + if (previousBeat.status === DOWN) { + retries = 0; + } + } else { + if (previousBeat.status === UP) { + retries = 0; + } } } }