Skip to content

fix: prevent empty/failed streaming responses in OpenCode proxy#13

Open
BP602 wants to merge 1 commit intorynfar:mainfrom
BP602:fix/proxy-stream-reliability
Open

fix: prevent empty/failed streaming responses in OpenCode proxy#13
BP602 wants to merge 1 commit intorynfar:mainfrom
BP602:fix/proxy-stream-reliability

Conversation

@BP602
Copy link

@BP602 BP602 commented Feb 6, 2026

Why

OpenCode requests were intermittently failing with connection reset by peer or returning empty answers. Logs showed two concrete causes:

  • Bun server idle timeout closed active SSE responses, then stream writes crashed against a closed controller
  • stream event filtering could incorrectly drop text events, producing empty output even when upstream completed

What changed

  • hardened SSE enqueue/close handling to avoid closed-controller cascades
  • added configurable CLAUDE_PROXY_IDLE_TIMEOUT_SECONDS to support long-lived streams
  • fixed stream event forwarding behavior so text deltas are not incorrectly skipped
  • split debug levels so baseline diagnostics stay useful while noisy stream internals are optional

Result

  • streaming responses stay open long enough to complete
  • no closed-controller error loops after disconnects/timeouts
  • OpenCode receives non-empty responses consistently in tested scenarios

@BP602 BP602 changed the title fix: improve streaming reliability and debug gating fix: prevent empty/failed streaming responses in OpenCode proxy Feb 6, 2026
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.

1 participant