[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 <noreply@anthropic.com>
Signed-off-by: Stanislaw Grams <stanislawgrams@gmail.com>
This commit is contained in:
2026-02-13 08:46:25 +01:00
parent 8b9da52fe7
commit 0b7158f465
@@ -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) {