From 0b7158f465cdd515abe272bffdbbdbacc370b04c Mon Sep 17 00:00:00 2001 From: Stanislaw Grams Date: Fri, 13 Feb 2026 08:46:25 +0100 Subject: [PATCH] [fix](trx-frontend-http): prevent browser hang on logout Replace location.reload() with disconnect() + auth gate to prevent browser hang when logging out. The full page reload was causing issues with resource loading and event source reconnection timers. Changes: - Add disconnect() function to cleanly close EventSource connections and clear all timers (esHeartbeat, reconnectTimer) - authLogout() now disconnects locally and shows auth gate instead of reloading the page - Faster logout experience without full page reload Co-Authored-By: Claude Opus 4.6 Signed-off-by: Stanislaw Grams --- .../trx-frontend-http/assets/web/app.js | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/trx-client/trx-frontend/trx-frontend-http/assets/web/app.js b/src/trx-client/trx-frontend/trx-frontend-http/assets/web/app.js index 1fa03c6..c86747e 100644 --- a/src/trx-client/trx-frontend/trx-frontend-http/assets/web/app.js +++ b/src/trx-client/trx-frontend/trx-frontend-http/assets/web/app.js @@ -48,9 +48,14 @@ async function authLogout() { const resp = await fetch("/auth/logout", { method: "POST" }); if (!resp.ok) throw new Error("Logout failed"); authRole = null; - location.reload(); + // Disconnect and show auth gate without page reload + disconnect(); + document.getElementById("content").style.display = "none"; + updateAuthUI(); + showAuthGate(false); } catch (e) { console.error("Logout failed:", e); + showAuthError("Logout failed"); } } @@ -909,6 +914,27 @@ function connect() { }, 5000); } +function disconnect() { + // Close event sources + if (es) { + es.close(); + es = null; + } + if (decodeSource) { + decodeSource.close(); + decodeSource = null; + } + // Clear timers + if (esHeartbeat) { + clearInterval(esHeartbeat); + esHeartbeat = null; + } + if (reconnectTimer) { + clearTimeout(reconnectTimer); + reconnectTimer = null; + } +} + async function postPath(path) { const resp = await fetch(path, { method: "POST" }); if (resp.status === 401 || resp.status === 403) {