fix: time out stalled streaming error bodies - #286
Merged
franciscojavierarceo merged 1 commit intoSep 11, 2026
Merged
Conversation
Signed-off-by: Chuyue Wang <stevenwang0805@outlook.com>
StevenWang-CY
requested review from
bbrowning,
franciscojavierarceo,
haoshan98,
jiahuei,
leseb,
maralbahari,
noobHappylife,
qandrew and
tjtanaa
as code owners
September 11, 2026 15:36
franciscojavierarceo
approved these changes
Sep 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A streaming request can hang after the upstream sends a 429/5xx response: successful SSE reads honor
STREAMING_CHUNK_TIMEOUT_S, but reading an HTTP error body waits indefinitely. Reproduce with a one-second configured timeout and an upstream that sends 429 headers plus a partial diagnostic, then keeps the body open.Apply the existing per-chunk timeout to error-body reads in executor-managed Responses streaming and Messages tool-loop requests, including initial and subsequent inference requests. The existing upstream-error object retains its status and processed headers, and adapters keep their current HTTP/SSE/WebSocket error formats. A timed-out diagnostic is discarded using the existing unreadable-body policy; a complete body is preserved. The timeout begins after response headers arrive, resets on each chunk, and remains disabled at zero. Non-streaming callers retain their existing timeout behavior.
Test Plan
STREAMING_CHUNK_TIMEOUT_Senvironment variable: unchanged main remains pending beyond a 3.2-second watchdog, while the patch finishes in about one/two seconds for one/two-second settings and closes the stalled upstream body. Twelve cases per binary (24 total) also confirm zero timeout, progressing chunks, delayed headers, non-streaming compatibility, preserved errors, no extra inference, and empty failed-request storage.Validation uses deterministic local upstreams and real HTTP/WebSocket gateways. Three installation-only Python tests and one existing Rust doctest remain skipped/ignored. No live model, GPU, cross-platform, or performance validation is claimed.