Repository navigation
Description
What do you want to change?
Two small additions to the HTTP transport:
- Make the connect-phase timeout configurable.
configureHttpDispatcher()passesautoSelectFamilyAttemptTimeoutto undici'sconnectbut nottimeout, so a stalled TCP+TLS connect is aborted at undici's 10s default.httpIdleTimeoutMsandretry.provider.timeoutMsonly cover headers/body. Anet.connectTimeoutMssetting (default 30s) would leave fast networks unchanged. - Expose request-level transport diagnostics. A connect timeout, a TLS stall, a proxy CONNECT failure and a provider timeout all surface as the same
Request timed out., with no phase or error code. Anhttp_requestextension event (host, status, connect/TLS/TTFB timings, error code) — or at least the phase and duration in the error — would make this diagnosable from an extension.
Why?
On 1.3.0 (Linux x86_64), deepseek/deepseek-flash behind a local proxy fails every request with Request timed out. after ~10.5s and retries 3x (~56s total). Direct connectivity is fine: NO_PROXY=api.deepseek.com succeeds in ~1.2s, and curl --noproxy '*' has ~0.2s TTFB. #11106 described the same root cause; that report was later retracted as a firewall issue, but the missing connect.timeout is still there. I am not asking to change the default for everyone — only to make the connect phase configurable.
The exact reproduction and timings are in the fold below.
Minimal reproduction (proxy stub, commands, timings)
A proxy that accepts TCP, answers CONNECT with 200, then stalls the TLS handshake. Save as stall-tls-proxy.js:
const net = require("node:net");
net.createServer((socket) => {
let connected = false;
socket.on("data", (chunk) => {
if (!connected && chunk.toString("latin1").startsWith("CONNECT")) {
connected = true;
socket.write("HTTP/1.1 200 Connection established\r\n\r\n"); // then never forward
}
});
socket.on("error", () => {});
}).listen(7897, "127.0.0.1");Then:
node stall-tls-proxy.js &
# 1) connect phase stalls: 4 attempts x ~10.5s + backoff, ~56s total
HTTPS_PROXY=http://127.0.0.1:7897 HTTP_PROXY=http://127.0.0.1:7897 \
pi -ne -p --no-session --model deepseek/deepseek-flash "Reply with OK"
# 2) same proxy, direct for the API host: ~1.2s
HTTPS_PROXY=http://127.0.0.1:7897 HTTP_PROXY=http://127.0.0.1:7897 \
NO_PROXY=api.deepseek.com \
pi -ne -p --no-session --model deepseek/deepseek-flash "Reply with OK"Observed on 1.3.0, Linux x86_64:
| Command | Result |
|---|---|
| (1) | Request timed out. x4; 10460–10499 ms per attempt; ~56.2 s total |
| (2) | OK in ~1.25 s |
HTTPS_PROXY=http://192.0.2.1:7899 (blackhole TCP) |
same ~56.2 s as (1) |
pi -ne disables every extension, so this is core. Any model works here; the request fails before the provider is reached. NO_PROXY=api.deepseek.com and curl --noproxy '*' both work, which points at the connect phase, not the provider.
How?
connect: { ..., timeout: connectTimeoutMs ?? 30_000 }inconfigureHttpDispatcher(), plus a setting.- Emit
http_request, or add timings/error toafter_provider_response, and anet.logLevel. NO_PROXYalready works (fix(ai): match subdomains and root domains in NO_PROXY #8737), so no separatenoProxysetting is needed on my side.
Happy to implement this if the shape is acceptable. Version 1.3.0, Linux x86_64.
(Drafted with an AI assistant from my own reproduction notes; I verified the reproduction and timings myself. Happy to rewrite or adjust anything.)
Activity
github-actions commentedon Oct 19, 2026
This issue was auto-closed. All issues from new contributors are auto-closed by default.
Maintainers review auto-closed issues daily and reopen worthwhile ones. Issues that do not meet the quality bar in CONTRIBUTING.md will not be reopened or receive a reply.
If a maintainer replies
lgtmion one of your issues, your future issues will stay open. If a maintainer replieslgtm, your future issues and PRs will stay open. The command must be at the start of the reply (optionally after one or more@usernamementions) or at the end.See CONTRIBUTING.md.