From dc0775f7df2d490c6a65c14115eb399e666f8b8b Mon Sep 17 00:00:00 2001 From: Smittix Date: Thu, 26 Feb 2026 22:04:32 +0000 Subject: [PATCH] morse: guard in-flight status polls from overriding stop state The previous stopPromise guard only prevented new polls from being dispatched. Polls already in-flight before stop was clicked could still return with running=true and override the stopping lifecycle, causing SSE reconnection and an apparent restart loop. Add a second guard in the .then() handler to check stopPromise/lifecycle before acting. Co-Authored-By: Claude Opus 4.6 --- static/js/modes/morse.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/static/js/modes/morse.js b/static/js/modes/morse.js index 69d250f..860d03d 100644 --- a/static/js/modes/morse.js +++ b/static/js/modes/morse.js @@ -421,6 +421,8 @@ var MorseMode = (function () { .then(function (r) { return parseJsonSafe(r); }) .then(function (data) { if (!data || typeof data !== 'object') return; + // Guard against in-flight polls that were dispatched before stop + if (state.stopPromise || state.lifecycle === 'stopping') return; if (data.running) { if (data.state === 'starting') {