fix: move retry reset logic to api-router determineStatus

This commit is contained in:
Ian Macabulos 2026-01-20 23:35:37 +08:00
parent e6eb8f327b
commit 82d520e534
2 changed files with 7 additions and 12 deletions

View File

@ -447,20 +447,8 @@ class Monitor extends BeanModel {
if (!previousBeat || this.type === "push") { if (!previousBeat || this.type === "push") {
previousBeat = await R.findOne("heartbeat", " monitor_id = ? ORDER BY time DESC", [this.id]); previousBeat = await R.findOne("heartbeat", " monitor_id = ? ORDER BY time DESC", [this.id]);
if (previousBeat) { if (previousBeat) {
retries = previousBeat.retries; retries = previousBeat.retries;
// 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;
}
}
} }
} }

View File

@ -598,6 +598,13 @@ function determineStatus(status, previousHeartbeat, maxretries, isUpsideDown, be
status = flipStatus(status); status = flipStatus(status);
} }
// This ensures that any previous retry count is cleared immediately when the monitor recovers.
if (status === UP) {
bean.retries = 0;
bean.status = status;
return;
}
if (previousHeartbeat) { if (previousHeartbeat) {
if (previousHeartbeat.status === UP && status === DOWN) { if (previousHeartbeat.status === UP && status === DOWN) {
// Going Down // Going Down