From ea10d89f51fbba6d15ec9f4e4794817de5d85bc8 Mon Sep 17 00:00:00 2001 From: Aram Akhavan Date: Sat, 28 May 2022 19:57:45 -0700 Subject: [PATCH] show correct down message for first tick --- server/model/monitor.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/server/model/monitor.js b/server/model/monitor.js index ee7b4f43..643d34a6 100644 --- a/server/model/monitor.js +++ b/server/model/monitor.js @@ -370,13 +370,13 @@ class Monitor extends BeanModel { log.debug("monitor", `[${this.name}] Checking monitor at ${dayjs().format("YYYY-MM-DD HH:mm:ss.SSS")}`); const bufferTime = 1000; // 1s buffer to accommodate clock differences - // If the previous beat was nonexistent, down or pending we use the regular - // beatInterval/retryInterval in the setTimeout further below if (previousBeat) { const msSinceLastBeat = dayjs.utc().valueOf() - dayjs.utc(previousBeat.time).valueOf(); log.debug("monitor", `[${this.name}] msSinceLastBeat = ${msSinceLastBeat}`); + // If the previous beat was down or pending we use the regular + // beatInterval/retryInterval in the setTimeout further below if (previousBeat.status !== UP || msSinceLastBeat > beatInterval * 1000 + bufferTime) { throw new Error("No heartbeat in the time window"); } else { @@ -392,6 +392,8 @@ class Monitor extends BeanModel { this.heartbeatInterval = setTimeout(beat, timeout); return; } + } else { + throw new Error("No heartbeat in the time window"); } } else if (this.type === "steam") {