Skip to content

Commit 56a50f5

Browse files
authored
fix: disconnect EventSource when navigating away from session detail (#512)
## Problem When navigating from a session detail page to the sessions list page, the frontend would hang with all network requests stuck in "pending" state. This only occurred in OpenShift deployments, not locally. The root cause: the EventSource (SSE) connection wasn't being cleaned up when unmounting the session detail component. This left the connection open and blocked the browser's connection pool (6 concurrent connections per domain). ## Solution Added a cleanup function in the useEffect hook that calls `aguiStream.disconnect()` when the component unmounts. This properly closes the EventSource connection. ## Changes - **components/frontend/src/app/projects/[name]/sessions/[sessionName]/page.tsx**: Added return cleanup function in the AG-UI connection useEffect ## Testing 1. Navigate to a session detail page (connection opens) 2. Navigate back to sessions list (connection now properly closes) 3. All network requests work normally - no more hanging ## Impact - ✅ Fixes frontend hanging on navigation - ✅ Prevents resource leaks from unclosed connections - ✅ No breaking changes - purely additive cleanup - ✅ MVP fix - minimal changes for maximum impact
1 parent 903f020 commit 56a50f5

File tree

1 file changed

+8
-1
lines changed
  • components/frontend/src/app/projects/[name]/sessions/[sessionName]

1 file changed

+8
-1
lines changed

components/frontend/src/app/projects/[name]/sessions/[sessionName]/page.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,14 @@ export default function ProjectSessionDetailPage({
230230
hasConnectedRef.current = true;
231231
aguiConnectRef.current();
232232
}
233-
}, [projectName, sessionName]);
233+
234+
// CRITICAL: Disconnect when navigating away to prevent hung connections
235+
return () => {
236+
console.log('[Session Detail] Unmounting, disconnecting AG-UI stream');
237+
aguiStream.disconnect();
238+
hasConnectedRef.current = false;
239+
};
240+
}, [projectName, sessionName, aguiStream]);
234241

235242
// Auto-send initial prompt (handles session start, workflow activation, restarts)
236243
// AG-UI pattern: Client (or backend) initiates runs via POST /agui/run

0 commit comments

Comments
 (0)