From 158aca42a262a10d73d9596a50b53e42930a949d Mon Sep 17 00:00:00 2001 From: ravjotb Date: Wed, 29 Jul 2026 16:35:38 -0700 Subject: [PATCH] Handle monitor stop gracefully when metrics server is dead Signed-off-by: ravjotb --- apps/server/src/actions/monitorAction.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/apps/server/src/actions/monitorAction.ts b/apps/server/src/actions/monitorAction.ts index 23c3a367..c7b7315f 100644 --- a/apps/server/src/actions/monitorAction.ts +++ b/apps/server/src/actions/monitorAction.ts @@ -106,7 +106,16 @@ async function runMonitorForNode( }) } } catch (error) { - sendMonitorError(ws, replyId, error) + // If we were trying to stop and the metrics server is dead, + // report monitor as stopped — it's not running anywhere. + if (monitorAction === "stop") { + sendMonitorFulfilled(ws, replyId, { monitorRunning: false, checkAt: null, startedAt: null }) + getOtherWatchers(watcherId, ws).forEach((watcher) => { + sendMonitorFulfilled(watcher, replyId, { monitorRunning: false, checkAt: null, startedAt: null }) + }) + } else { + sendMonitorError(ws, replyId, error) + } } }