Skip to content

fix(ai): honor chunkTimeout on HTTP SSE streams - #46802

Closed
holny wants to merge 2 commits into
anomalyco:v2from
holny:sse-chunk-timeout
Closed

fix(ai): honor chunkTimeout on HTTP SSE streams#46802
holny wants to merge 2 commits into
anomalyco:v2from
holny:sse-chunk-timeout

Conversation

@holny

@holny holny commented Sep 2, 2026

Copy link
Copy Markdown

Issue for this PR

Fixes #46692

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

chunkTimeout was accepted in provider settings but never read on the native path — HttpOptions had 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.

  • Add chunkTimeout (ms) to HttpOptions and thread it through mergeHttpOptions
  • Apply it as a per-chunk timeout on the response stream in the HTTP transport (transport/http.ts), failing with a typed TransportError (chunk-timeout) when no chunk arrives within the window
  • Add chunkTimeout to ProviderPackage.Settings and wire it through the azure provider first; remaining providers share the same config() pattern and can adopt the same field
  • Preserve chunkTimeout when model.request hooks rebuild HttpOptions

How did you verify your code works?

  • New test/chunk-timeout.test.ts: a stalled SSE stream (one frame then silence) aborts with code: chunk-timeout under a real clock; mergeHttpOptions keeps the rightmost configured value
  • bun typecheck + bun test in packages/ai (954 passing) and packages/core (only pre-existing environment-dependent failures in git-worktree/pty tests, confirmed on a clean baseline)

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

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). Preserve the field when model.request hooks rebuild HttpOptions.
@holny

holny commented Sep 2, 2026

Copy link
Copy Markdown
Author

Fixes #46692 — the linked-issue check doesn't resolve the keyword from a fork PR, so referencing it here directly.

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@holny

holny commented Sep 6, 2026

Copy link
Copy Markdown
Author

Another nudge — checks still green and the chunkTimeout wiring is unchanged since I opened it. Happy to rework anything if the approach needs adjusting.

@holny

holny commented Sep 8, 2026

Copy link
Copy Markdown
Author

Bumping this one again — happy to rebase onto the latest v2 if that helps move it along, or adjust the approach if there's any concern with the chunkTimeout wiring.

@holny holny closed this by deleting the head repository Sep 9, 2026
@holny

holny commented Sep 9, 2026

Copy link
Copy Markdown
Author

Superseded by #48158 - this PR's head fork was accidentally deleted on 2026-09-09 (not intentional); re-filed so the review can continue. Sorry for the noise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant