fix: disable Bun idle timeout that cut long streaming responses - #268
Open
graehl wants to merge 1 commit into
Open
fix: disable Bun idle timeout that cut long streaming responses#268graehl wants to merge 1 commit into
graehl wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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/messagessends no bytes while atool_useinput is being generated — allinput_json_deltaevents arrive in one burst at the end (I measured 41s of silence before a ~1900-delta burst).Bun.servedefaultsidleTimeoutto 10 seconds of socket inactivity, so any silent stretch >10s kills the client connection mid-stream (Bun logsrequest 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'sserve().Verified: the same 41s-silent-gap stream that previously got cut completes cleanly with the timeout disabled;
bun testpasses.🤖 Generated by Fable