fix(quota): raise Node's 250ms connect-attempt cap for provider fetches (#3404)

Node's happy-eyeballs default (autoSelectFamilyAttemptTimeout=250ms)
aborts every connect attempt to provider endpoints whose TCP handshake
exceeds 250ms, so quota fetches from Node processes fail with
"fetch failed" while the Bun-based opencode CLI path succeeds (#3399).
Raise the per-attempt cap to 5s via a shared applyConnectAttemptTimeout()
helper called from the two Node entrypoints that host the quota module:
the Electron main process and the openchamber CLI. Family autoselection
stays enabled (::1 and IPv6→IPv4 fallback preserved); runtimes without
the setter are a no-op.
This commit is contained in:
ouyangjian28
2026-09-07 20:25:24 +03:00
committed by GitHub
parent fc61b10109
commit c779b765d9
4 changed files with 72 additions and 0 deletions
+7
View File
@@ -72,6 +72,13 @@ import {
printJson,
logStatus,
} from './cli-output.js';
import { applyConnectAttemptTimeout } from '../server/lib/network-defaults.js';
// The CLI process performs provider fetches (quota/usage, update notes) under
// Node/undici, whose happy-eyeballs default aborts each connect attempt after
// 250ms — distant provider endpoints routinely need longer handshakes, surfacing
// as "fetch failed" (#3399). No-op on runtimes without the setter.
applyConnectAttemptTimeout();
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);