Repository navigation
Description
Summary
Model turns in the desktop app fail after ~40s with the "Check your connection / We couldn't reach the server" panel, even though the network is fine (browser, curl, and the CLI all reach the API). The bundled agent engine calls https://api.commandcode.ai with Node's fetch, which dies with TypeError: fetch failed → AggregateError [ETIMEDOUT, ENETUNREACH, ...].
The same request from Chromium inside the same app process (net.fetch) returns 200.
Root cause
Node 24.22.0 (bundled in Electron 43.8.1) uses happy-eyeballs (autoSelectFamily: true) with a 250 ms per-attempt budget (net.getDefaultAutoSelectFamilyAttemptTimeout() === 250).
On this network, the TCP connect to api.commandcode.ai takes ~271 ms (steady across all three Cloudflare IPv4s; ICMP RTT to the same IPs is only 26 ms, so it is a handshake/TLS-front latency, not a broken link).
So for a host that publishes both A and AAAA records — and this machine has no global IPv6 route — Node does:
- try IPv4 → ETIMEDOUT at 250 ms (connect needed ~271 ms)
- try IPv6 → ENETUNREACH
- give up ⇒
fetch failedafter ~1 s
curl, undici under system Node, and the CLI (Node 26) all succeed, because Node 26's default attempt timeout is 500 ms. That's the whole difference.
Expected behavior
Model turns reach the API and stream normally, as they do from the CLI.
Actual behavior
Every turn ends stopReason: "run_error" with Error: Connection error. / the "Check your connection" panel. Notices also fail at startup: [notices] notices refresh failed { error: 'TypeError: fetch failed' }.
Steps to reproduce
- Network where TCP connect to
api.commandcode.aiexceeds 250 ms but is healthy (e.g. a Tailscale-connected host with AAAA records resolving but no global IPv6 route). - Open the desktop app, send any message.
- Turn fails ~1 s into the request; the retryable "Check your connection" panel appears.
Environment
- GUI version: 0.1.64 (AppImage,
X-AppImage-Version=0.1.62in the desktop entry) - Linux (Omarchy / Arch), kernel
7.2.15-1-omarchy, Hyprland/Wayland - Electron 43.8.1, bundled Node 24.22.0, Chrome 150
- CLI
command-codeon Node 26.13.1 works on the same machine - Trace IDs from failing turns:
2b935929a267ef9ccb8cd60373091aac,49e1bad1623732f56357ea9d7c21a789,f5b1f93e9007f41b3af13cf197637b40
Evidence
Measured inside the app's own Electron binary (replacement main.js, same command-code runtime):
default autoSelectFamily = true
default attemptTimeout = 250
A-baseline FAIL ETIMEDOUT 1054ms
B-no-select OK 200 865ms <- net.setDefaultAutoSelectFamily(false)
C-timeout1500 OK 200 862ms <- net.setDefaultAutoSelectFamilyAttemptTimeout(1500)
node-fetch https://api.commandcode.ai/ FAIL fetch failed | cause: ETIMEDOUT
cause.errors = [ETIMEDOUT, ENETUNREACH, ETIMEDOUT, ENETUNREACH, ETIMEDOUT, ENETUNREACH]
net.fetch (Chromium) OK 200 901ms <- same process, same moment
Connect latency:
104.26.8.108 443 [266, 275, 271] ms
104.26.9.108 443 [263 ms]
172.67.69.147 443 [291 ms]
1.1.1.1 443 [31, 25, 21] ms
ping 104.26.8.108 -> 26 ms avg
Confirming it is the missing-IPv4-immediately problem (IPv4-only resolution works):
T0-default FAIL ETIMEDOUT 1038ms
T1-hosts-single-ipv4 OK 200 1683ms
T2-ipv4-only-multi OK 200 1358ms
Suggested fixes (in order of preference)
- Raise the attempt budget for the engine's dispatcher to 1000–1500 ms, or
- Pass
{ autoSelectFamily: false }/ prefer IPv4 when the host has no usable IPv6 route, or - Treat a per-attempt
ETIMEDOUTas retryable before surfacing "Check your connection" (today a single 250 ms race loss renders as a network outage). - Longer term: this error is classified as a connectivity failure; a slow-but-healthy handshake shouldn't map to "check your internet".
NODE_OPTIONS=--network-family-autoselection-attempt-timeout=1500 would fix it locally, but Electron has the EnableNodeOptionsEnvironmentVariable fuse off, so it is stripped — hence the code-level ask.
Additional context
Reproduced deterministically on this machine against the shipped 0.1.64 binary. Happy to test a build.
Activity