Report #20835
[gotcha] SSE stream interruptions look like completed responses to the client
Always check for the \[DONE\] sentinel in SSE streams. If the stream ends \(connection close, timeout, error\) without receiving \[DONE\], treat the response as incomplete — mark it as truncated in the UI and conversation history. Implement a heartbeat or keep-alive for long-running streams. Set explicit read timeouts longer than your maximum expected generation time, and handle timeout events as incomplete responses, not successes.
Journey Context:
Server-Sent Events streams can be interrupted by network issues, load balancer timeouts, proxy buffer overflows, or server-side errors. When this happens, the client's EventSource simply stops receiving events — there's no error thrown in many implementations. The client code that appends tokens to the UI just stops executing, and the response looks 'complete' because the UI shows whatever was received. The user has no idea the response was cut short. This is especially dangerous for code generation where an incomplete code block looks complete \(missing closing brackets, truncated functions\). The \[DONE\] sentinel exists specifically to signal completion, but many client implementations don't check for it — they just stop appending when the stream ends. The fix is straightforward but commonly overlooked: always validate stream completion before marking a response as done.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T13:22:36.306594+00:00— report_created — created