fix(ai): honor chunkTimeout on HTTP SSE streams - #48158
Conversation
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
The following comment was made by an LLM, it may be inaccurate: Based on my search, I found related PRs that may be duplicates or closely related to PR #48158: Potentially Related PRs:
These PRs may have overlapping concerns with honoring |
28f8cf5 to
5036405
Compare
The chunkTimeout provider setting was accepted but never read on the native path: HttpOptions had no field, the HTTP transport applied no stall guard, and settings dropped it silently. A stalled provider stream was bounded only by the OS socket. Add chunkTimeout to HttpOptions, apply it as a per-chunk timeout on the response stream in the HTTP transport, and thread it through provider settings (azure wired first; the remaining providers share the same config() pattern). The field flows through route defaults and mergeHttpOptions, which resolve after session model.request hooks, so no core-side preservation is needed.
5036405 to
db8f73c
Compare
Issue for this PR
Fixes #46692
Type of change
What does this PR do?
chunkTimeoutwas accepted in provider settings but never read on the native path —HttpOptionshad no field, the HTTP transport applied no stall guard, and the setting was silently dropped. A stalled provider stream was bounded only by the OS socket.chunkTimeout(ms) toHttpOptionsand thread it throughmergeHttpOptionstransport/http.ts), failing with a typedTransportError(chunk-timeout) when no chunk arrives within the windowchunkTimeouttoProviderPackage.Settingsand wire it through the azure provider first; remaining providers share the sameconfig()pattern and can adopt the same fieldchunkTimeoutwhenmodel.requesthooks rebuildHttpOptionsHow did you verify your code works?
test/chunk-timeout.test.ts: a stalled SSE stream (one frame then silence) aborts withcode: chunk-timeoutunder a real clock;mergeHttpOptionskeeps the rightmost configured valuebun typecheck+bun testinpackages/ai(954 passing) andpackages/core(only pre-existing environment-dependent failures in git-worktree/pty tests, confirmed on a clean baseline)Checklist
Supersedes #46802 — the PR head fork was accidentally deleted on 2026-09-09 (not intentional, see the notification comment there); re-filing so the review can continue. Original conversation: #46802