fix: handle upside-down mode in retry reset logic

This commit is contained in:
Ian Macabulos 2026-01-18 09:33:30 +08:00
parent cbc1336b65
commit 735180e8e3

View File

@ -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;
}
}
}
}