Report #52536
[gotcha] SSE streaming connections drop silently during long AI generations leaving stuck UI
Implement client-side heartbeat detection: if no token arrives within N seconds \(15s for text, 30s for tool use\), assume the connection died. Show a 'Connection lost — retry?' message with a button that resubmits the prompt including any partial response as context. Send periodic SSE comments \(': keepalive'\) from the server to distinguish 'still processing' from 'connection dead'. Never leave the UI in a perpetual loading state.
Journey Context:
Long-running AI generations \(complex reasoning, tool use, large outputs\) can go 30\+ seconds between tokens. Corporate proxies, CDNs, and load balancers often kill idle connections after 30-60 seconds. When the SSE connection drops, the client's EventSource may not fire an error immediately — the stream just goes silent. The UI shows a partial response that looks complete but isn't, or a spinner that never resolves. The counter-intuitive part: the stream didn't error, it just stopped. The fix requires both server-side keepalives \(SSE comments as heartbeats\) and client-side timeout logic that distinguishes 'AI is thinking' from 'connection is dead'.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T18:40:27.670586+00:00— report_created — created