Files
26cea2fa8b fix: stop undici's 5-minute idle timeout killing local model requests (#15024)
* fix(lmstudio): disable undici's idle-body timeout so slow local generations aren't killed mid-stream

* fix(lmstudio): compose the bodyTimeout override onto the active dispatcher instead of replacing it

* fix(vscode): disable undici idle timeouts for local model providers

Node's fetch applies undici's default 300s headersTimeout/bodyTimeout,
each measuring time since the last byte received. Local servers
(LM Studio, Ollama) legitimately go silent for longer while processing a
large prompt (headers arrive immediately, then no body bytes until the
first token), so long requests died mid-task with
'terminated: BodyTimeoutError (UND_ERR_BODY_TIMEOUT)' even though the
server was still generating.

Route LM Studio and Ollama inference through a fetch bound to an
EnvHttpProxyAgent with headersTimeout/bodyTimeout disabled. This calls
undici's own fetch rather than global fetch because VS Code's
http.fetchAdditionalSupport patch replaces caller-supplied dispatchers
with its own default-timeout Agent. Cancellation stays with each
request's AbortSignal.

Fixes #13464

Co-authored-by: Saoud Rizwan <saoudrizwan@users.noreply.github.com>

* fix(vscode): disable undici idle timeouts for providers that may run a local model

Combine the two earlier drafts: dispatch through undici's own fetch so the
override survives VS Code's global fetch wrapper, and keep the env-var
proxy agent so JetBrains proxy support is unchanged. Widen the provider
set from LM Studio and Ollama to also cover OpenAI Compatible and LiteLLM,
which telemetry shows carry most of the UND_ERR_BODY_TIMEOUT failures.

The net test now exercises real undici fetch against a local server that
flushes headers and then stays silent, with a short-timeout control to
prove the silence is long enough to trip the default timer.

* test(vscode): keep the idle-timeout net test off any machine-level proxy

* chore: drop the changeset file, the repo no longer uses changesets

* fix(vscode): only skip idle timeouts when the base URL is on the local network

OpenAI Compatible and LiteLLM often point at remote corporate gateways.
On VS Code, fetchWithoutIdleTimeouts bypasses the host's proxy handling
(http.proxy, OS/PAC proxy, proxyStrictSSL), so routing those through it
would break proxied setups. Gate on the base URL as well: loopback,
private/link-local/CGNAT ranges, single-label hosts and .local/.internal
names get the idle-timeout-free fetch; remote gateways keep the
proxy-aware fetch and its dead-connection cap.

Co-authored-by: Saoud Rizwan <saoudrizwan@users.noreply.github.com>

* fix(vscode): keep loopback direct in fetchWithoutIdleTimeouts, cover 0.0.0.0 and mapped IPv4

EnvHttpProxyAgent sends loopback through http_proxy whenever no_proxy is
unset, which VS Code's own resolver never does. Pick a plain Agent for
loopback hosts and the env-var proxy agent for everything else, both
with idle timeouts off. The local-network gate now also accepts 0.0.0.0
and IPv4-mapped IPv6 addresses, which Ollama and LM Studio print when
bound to all interfaces.

The net test now runs with HTTP_PROXY set and NO_PROXY unset against a
recording CONNECT proxy: loopback never touches it, an unroutable host
goes through it, and neither path has an idle timeout.

* fix(vscode): match loopback by address so IPv4-mapped IPv6 stays direct

The URL parser rewrites [::ffff:127.0.0.1] to [::ffff:7f00:1], which a
string match on "127." misses. Use a BlockList, which checks mapped
addresses against the IPv4 rules, for the loopback bypass and drop the
now-redundant unwrapping in the local-network gate.

---------

Co-authored-by: lizhe <marshal_li_b@163.com>
Co-authored-by: Saoud Rizwan <7799382+saoudrizwan@users.noreply.github.com>
Co-authored-by: Saoud Rizwan <saoudrizwan@users.noreply.github.com>
2026-10-13 21:44:25 +02:00
..
2026-05-25 21:35:59 +02:00
2026-05-25 21:35:59 +02:00
2026-06-24 14:11:30 +09:00
2026-06-03 18:58:27 +02:00
2026-10-13 07:43:52 -07:00
2026-05-25 21:35:59 +02:00
2026-05-25 21:35:59 +02:00