Report #86078
[gotcha] Network interruption during AI streaming silently renders a partial response as if it were complete
Implement three layers of stream health monitoring: \(1\) track whether the final chunk contained a valid \`finish\_reason\` — if the stream ended without one, the response is incomplete, \(2\) set a maximum inter-token timeout \(e.g., 30 seconds\) — if no token arrives within this window, assume the stream died, \(3\) handle SSE/EventSource \`error\` and \`close\` events to distinguish normal completion from abnormal termination. Always mark incomplete responses in the UI with a 'response interrupted' indicator and a retry option.
Journey Context:
Streaming responses can be interrupted by network drops, server timeouts, proxy disconnections, CDN issues, or the browser throttling background tabs. When this happens, your token accumulation loop simply stops receiving data. Without explicit checking, the accumulated partial text is indistinguishable from a complete response — it just ends wherever the stream died, which might be mid-sentence or mid-word. This is distinct from the \`finish\_reason\` problem \(where the API explicitly tells you it stopped and why\). Here, the transport layer fails and the API never sends a termination signal. The stream just goes silent. Many implementations have no mechanism to detect this: they wait for the stream to close, and when it does \(due to network error\), they treat the accumulated text as complete. The fix requires treating stream health as a first-class concern.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T03:04:26.458304+00:00— report_created — created