Skip to content

fix: disable Bun idle timeout that cut long streaming responses - #268

Open
graehl wants to merge 1 commit into
ericc-ch:masterfrom
graehl:fix/bun-idle-timeout
Open

fix: disable Bun idle timeout that cut long streaming responses#268
graehl wants to merge 1 commit into
ericc-ch:masterfrom
graehl:fix/bun-idle-timeout

Conversation

@graehl

@graehl graehl commented Aug 5, 2026

Copy link
Copy Markdown

With Claude Code pointed at copilot-api, any large tool call (e.g. a big Edit) consistently died with "API Error: Connection closed mid-response", while small ones succeeded.

Cause: Copilot's /v1/messages sends no bytes while a tool_use input is being generated — all input_json_delta events arrive in one burst at the end (I measured 41s of silence before a ~1900-delta burst). Bun.serve defaults idleTimeout to 10 seconds of socket inactivity, so any silent stretch >10s kills the client connection mid-stream (Bun logs request timed out after 10 seconds. Pass idleTimeout to configure.). Slow time-to-first-byte responses hit the same limit. So the effective cap was "10 seconds of upstream silence", which large generations always exceed.

Fix: pass bun: { idleTimeout: 0 } through srvx's serve().

Verified: the same 41s-silent-gap stream that previously got cut completes cleanly with the timeout disabled; bun test passes.

🤖 Generated by Fable

Bun.serve defaults idleTimeout to 10s of socket silence. Copilot
/v1/messages sends no bytes while a tool_use input is generated (all
input_json deltas arrive in one burst at the end), so any tool call
taking >10s to produce - e.g. a large Claude Code Edit - was cut
mid-stream, surfacing client-side as "API Error: Connection closed
mid-response". Long time-to-first-byte responses hit the same limit.
Observed a 41s silent gap before an ~1900-delta burst on a large tool
input; with the timeout disabled the stream completes cleanly.
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