Skip to content

Make the connect timeout configurable and expose request-level transport diagnostics #11115

Closed as not planned

Description

@Ebotian

What do you want to change?

Two small additions to the HTTP transport:

  1. Make the connect-phase timeout configurable. configureHttpDispatcher() passes autoSelectFamilyAttemptTimeout to undici's connect but not timeout, so a stalled TCP+TLS connect is aborted at undici's 10s default. httpIdleTimeoutMs and retry.provider.timeoutMs only cover headers/body. A net.connectTimeoutMs setting (default 30s) would leave fast networks unchanged.
  2. 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. An http_request extension 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 } in configureHttpDispatcher(), plus a setting.
  • Emit http_request, or add timings/error to after_provider_response, and a net.logLevel.
  • NO_PROXY already works (fix(ai): match subdomains and root domains in NO_PROXY #8737), so no separate noProxy setting 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

  1. github-actions commented on Oct 19, 2026

    @github-actions
    Contributor

    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 lgtmi on one of your issues, your future issues will stay open. If a maintainer replies lgtm, your future issues and PRs will stay open. The command must be at the start of the reply (optionally after one or more @username mentions) or at the end.

    See CONTRIBUTING.md.

  2. added
    untriagedThis issue has been auto closed and has not been triaged
    on Oct 19, 2026
  3. added
    no-actionThis issue has been rejected after triage
    and removed
    untriagedThis issue has been auto closed and has not been triaged
    on Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    no-actionThis issue has been rejected after triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions