Skip to content

fix(streaming): prevent SSE idle disconnects and total stream timeouts#11

Merged
HisenWeb merged 1 commit into
HisenWeb:mainfrom
DKalien:codex/upstream-streaming-timeouts
Jul 20, 2026
Merged

fix(streaming): prevent SSE idle disconnects and total stream timeouts#11
HisenWeb merged 1 commit into
HisenWeb:mainfrom
DKalien:codex/upstream-streaming-timeouts

Conversation

@DKalien

@DKalien DKalien commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Summary

Fix long-running streaming responses that can be terminated while the upstream model is still working.

Root cause

The upstream main branch had two independent timeout paths:

  • The downstream Axum SSE response did not emit keep-alive comment frames, so Codex could hit stream_idle_timeout_ms during periods without model events.
  • OpenCodeGoClient used one reqwest client with ClientBuilder::timeout() for both normal and streaming requests. That timeout applies to the complete response, so a valid stream could be cut off after the normal request budget.

Changes

  • Add a 15-second downstream SSE keep-alive.
  • Split normal and streaming reqwest clients:
    • normal requests keep the total request timeout;
    • streaming requests use connect and per-read timeouts without a total response deadline.
  • Raise generated/example stream_idle_timeout_ms from 120 seconds to 360 seconds.
  • Add regression tests for idle SSE keep-alives, generated provider timeout settings, and streams that outlive the normal total timeout.

Validation

  • cargo test --all-targets --quiet
  • cargo test --lib --quiet
  • cargo check --all-targets --quiet

All passed locally.

Keep downstream SSE connections alive during upstream idle periods, use a read-timeout-only client for streaming requests, and align generated provider idle settings with the longer stream budget. Add regression coverage for both behaviors.

Upstream-Ref: HisenWeb/codex-opencode-adapter
@DKalien
DKalien marked this pull request as ready for review July 19, 2026 02:17
@HisenWeb
HisenWeb merged commit 75a4f37 into HisenWeb:main Jul 20, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants