From 32c1a74fcc3a77bf31986613e39d606602216281 Mon Sep 17 00:00:00 2001 From: Priyanka Punukollu Date: Sat, 28 Feb 2026 08:35:42 -0600 Subject: [PATCH] =?UTF-8?q?fix:=20sign=20out=20responds=20immediately=20?= =?UTF-8?q?=E2=80=94=20cancel=20pending=20requests=20with=20AbortControlle?= =?UTF-8?q?r?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Made-with: Cursor --- chat_ui.html | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/chat_ui.html b/chat_ui.html index 819b364c8..bd7e039af 100644 --- a/chat_ui.html +++ b/chat_ui.html @@ -5471,6 +5471,7 @@ let pendingWrite = null; // echoed back to agent on confirmation let sessionStats = { messages: 0, toolCalls: 0, latencies: [] }; let lastQuery = ''; // for retry + let chatAbortController = null; // abort pending fetch on sign out const chat = document.getElementById('chat'); const input = document.getElementById('input'); @@ -5687,10 +5688,12 @@ let agentBubbleEl = null; let agentMsgEl = null; + chatAbortController = new AbortController(); try { const _authToken = localStorage.getItem('gf_token') || ''; const res = await fetch('/chat/steps', { method: 'POST', + signal: chatAbortController.signal, headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${_authToken}` @@ -5807,11 +5810,14 @@ } catch (err) { thinkingEl.remove(); if (agentMsgEl) agentMsgEl.remove(); - addErrorMessage( - 'Could not reach the agent. Please try again.', - query - ); + if (err.name !== 'AbortError') { + addErrorMessage( + 'Could not reach the agent. Please try again.', + query + ); + } } finally { + chatAbortController = null; sendBtn.disabled = false; input.focus(); } @@ -8718,6 +8724,10 @@ // ── Sign out ── document.getElementById('logout-btn').addEventListener('click', () => { + if (chatAbortController) { + chatAbortController.abort(); + chatAbortController = null; + } localStorage.removeItem('gf_token'); localStorage.removeItem('gf_user_name'); localStorage.removeItem('gf_user_email');