Chunk-level stream timeout for ChatClient #375
DiegoGBrisa
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Problem
When an LLM provider hangs mid-stream (connection stays open but no chunks arrive), there's no built-in way to detect it and abort. The stream just sits there indefinitely. This happens more often than you'd expect with some providers — especially during high load or when tool execution takes longer than anticipated on the server.
You can pass an AbortSignal to the connection adapter, but that requires managing timers externally and resetting them on every chunk, which is boilerplate that every app ends up reimplementing.
Proposal
A streamTimeout option on ChatClient (and by extension useChat / framework wrappers) that aborts the stream if no chunk arrives within the specified duration:
The timeout resets on every received chunk, so it's a per-chunk idle timeout — not a total duration limit. When it fires, it triggers the same error flow as stop() or a network failure, so onError and status updates work as expected.
This could live in StreamProcessor or at the ChatClient level wrapping the connection's AsyncIterable.
Beta Was this translation helpful? Give feedback.
All reactions