Binary and ONNX downloads fail behind HTTP(S)_PROXY on Node.js with opaque "fetch failed" (err.cause dropped)
Problem
When running npx @cortexkit/aft@latest setup or npx @cortexkit/aft doctor --fix behind an HTTP/HTTPS proxy (http_proxy / https_proxy / HTTP_PROXY / HTTPS_PROXY), binary and ONNX Runtime downloads fail on Node.js with an opaque fetch failed message:
AFT binary download failed: could not reach GitHub to download the v0.68.0 binary (Failed to download AFT binary: fetch failed). Check your network connection or proxy.
Two things make this difficult to diagnose:
- Bun vs. Node.js runtime difference for
fetch(): OpenCode runs on Bun, wherefetch()honoursHTTP(S)_PROXY/NO_PROXYby default. However,npx @cortexkit/aft(and@cortexkit/aft-pi) runs on Node.js, where built-infetch(undici) ignoresHTTP(S)_PROXYunlessNODE_USE_ENV_PROXY=1or--use-env-proxyis set (Node >= 22.21 / 24). err.causeis dropped indownloader.tsandonnx-runtime.ts: BothdownloadBinary()(packages/aft-bridge/src/downloader.ts:350) anddownloadOnnxRuntime()(packages/aft-bridge/src/onnx-runtime.ts:800) log onlyerr.message("fetch failed"), discardingerr.cause(UND_ERR_CONNECT_TIMEOUT,ENOTFOUND,ECONNREFUSED, orAggregateError.errors).
Reproduction
On Node v24.21.0 behind a proxy (https_proxy=http://127.0.0.1:7890) where direct connections to release-assets.githubusercontent.com time out:
# Bypasses proxy -> fails after 10s (undici connectTimeout) with bare TypeError: fetch failed
env -u NODE_USE_ENV_PROXY https_proxy=http://127.0.0.1:7890 \
node -e 'fetch("https://github.com/cortexkit/aft/releases/download/v0.68.0/checksums.sha256").then(r => console.log(r.status))'
# Succeeds via proxy
NODE_USE_ENV_PROXY=1 https_proxy=http://127.0.0.1:7890 \
node -e 'fetch("https://github.com/cortexkit/aft/releases/download/v0.68.0/checksums.sha256").then(r => console.log(r.status))'
Proposed Fix
Keep aft-bridge free of global side effects (do not mutate Node's process-wide HTTP dispatcher from a library that also runs inside host processes) and fix the diagnostic gap:
- Walk
error.cause(andAggregateError.errors) when formatting fetch failures indownloadBinary()anddownloadOnnxRuntime(), and distinguish the 300s download timeout from external aborts. - When a download fails on Node.js with
HTTP(S)_PROXYset in the environment while neitherNODE_USE_ENV_PROXY=1nor--use-env-proxyis active, append an explicit hint:(HTTP(S)_PROXY is set, but Node.js fetch ignores it unless NODE_USE_ENV_PROXY=1 is set)
(Open question for maintainers: if you would also like aft-cli or aft-bridge to opt into http.setGlobalProxyFromEnv() on Node >= 24.14 when proxy env vars are present, happy to add that if desired.)