fix(upstream): REQUEST_TIMEOUT guards TTFB only, never the streamed body - #355
Merged
Conversation
The request-context deadline cut healthy long streams at the default 15m: a turn-heavy agent session died mid-stream while the connection was still feeding data (observed live). Move the bound to the transport's ResponseHeaderTimeout so it aborts only when response headers never arrive; the streamed body now runs until upstream EOF or the caller's context cancels (client disconnect). Control calls keep their own SessionCallTimeout ctx deadlines, unaffected. - client.go: transport.ResponseHeaderTimeout = c.requestTimeout - chat.go: drop the WithTimeout wrap around the chat request context - keycatalog.go: REQUEST_TIMEOUT description states TTFB-only semantics - client_chat_test.go: stream survives past REQUEST_TIMEOUT; stalled headers still abort near the bound - config-meta.json: regen fixture (FP_REGEN_FIXTURE=1)
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.
Problem
Healthy long streams were cut at
REQUEST_TIMEOUT(default 15m): the request-context deadline killed the body read mid-stream even while upstream kept feeding data. Observed live: turn-heavy agent sessions die at exactly the bound with no upstream error.Change
client.go:transport.ResponseHeaderTimeout = c.requestTimeout— the knob now bounds only the wait for response headers (TTFB).chat.go: removed thecontext.WithTimeoutwrap around the chat request; the streamed body runs until upstream EOF or the caller's context cancels (client disconnect).SessionCallTimeoutctx deadlines are tighter and untouched.keycatalog.go:REQUEST_TIMEOUTdescription now states TTFB-only semantics; fixture regenerated.Verification
TestChatStreamSurvivesPastRequestTimeout: 1.5s stream with 400ms knob — passes post-fix, failed pre-fix (context deadline exceeded at 400ms).TestChatTTFBTimeoutStillAborts: stalled headers still abort near the bound.