Keep a caller's headersTimeout and bodyTimeout in the fetch patch - #121
Open
Vivswan Shah (Vivswan) wants to merge 1 commit into
Open
Vivswan Shah (Vivswan) wants to merge 1 commit into
Vivswan Shah (Vivswan) wants to merge 1 commit into
Conversation
The fetch patch replaces the caller's dispatcher with its own Agent or ProxyAgent and carried over only allowH2, connect.ca, requestTls.ca, and proxyTls.ca. A caller that raised headersTimeout or bodyTimeout on its dispatcher, to let a long-running stream outlive undici's 300 s idle defaults, lost them: the replacement fell back to the defaults and the stream died at 300 s whatever the caller asked for. Carry both timeouts through getAgentOptions into createAgent and createProxyAgent, for the fetch patch and for the WebSocket dispatcher. Seen from an extension in Vivswan/litellm-vscode-chat#343.
5 tasks
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.
What this changes
Why
undici's
AgentandProxyAgentdefaultheadersTimeoutandbodyTimeoutto 300 s. A caller that streams for longer than that with pauses (an LLM reasoning for minutes between chunks) raises both on its dispatcher. Withhttp.proxySupportat its defaultoverride, or system certificates on, the fetch patch replaces that dispatcher and the timeouts do not come along, so the stream is closed at 300 s whatever the caller asked for. Extensions cannot work around it from their side.How
getAgentOptionsalso readsheadersTimeoutandbodyTimeoutfrom the caller'sAgentorProxyAgentoptions (both symbol paths) and returns them astimeouts.getAgent/createAgentandgetProxyAgent/createProxyAgenttake the timeouts and pass them to the undici constructors. The WebSocketProxyDispatcherthreads the same values.Proof
npm run compiletypechecks.UND_ERR_BODY_TIMEOUT; the extension has since moved tohttps.request, which the http patch handles without an idle clock, so this change is a courtesy for other callers of the fetch patch.