Repository navigation
Description
Summary
Every outbound HTTP call bb makes itself uses Node's global fetch with no dispatcher, so it silently ignores HTTP_PROXY / HTTPS_PROXY / NO_PROXY. Behind a mandatory proxy this breaks Settings → Usage limits for all three providers and every bb-owned ChatGPT/OpenAI call (thread titles, transcription, manager calls) — in a region where OpenAI and Anthropic block the IP, those requests come back HTTP 403. Agent turns mostly still work, because they run through the spawned provider CLI (codex, claude), which does its own proxying — which is what makes this look intermittent rather than total.
I expected bb to route its own requests through the proxy the environment declares, the way the push-notifications plugin already does with undici's EnvHttpProxyAgent.
Versions and environment
- bb 0.42.1, run with
npx bb-app@latest(matchesnpm view bb-app version= 0.42.1); source read atmain@06aeaa994942ae7527dc49d2268c1f801e8542a0 - Ubuntu 24.04.1 LTS on WSL2 (kernel 6.6.87.2-microsoft-standard-WSL2), Windows host
- Node v24.14.1
- Providers:
codex(codex-cli 0.153.4, ChatGPT subscription auth),claude-code(Claude Code 2.1.263),acp-cursor - Mandatory local HTTP proxy at
http://127.0.0.1:10808, exported asHTTP_PROXY/HTTPS_PROXY, withNO_PROXY=localhost,127.0.0.1. The proxy vars are present in the environment of every bb process (verified via/proc/<pid>/environfornpm exec bb-app, the server, and the host daemon).
Steps to reproduce
A. Universal repro — no blocked region needed. Point the proxy variables at a dead port. If bb honored them, every outbound request would fail with ECONNREFUSED; instead they succeed, proving the proxy is never consulted.
# 1. Proxy is ignored: request succeeds despite the proxy being unreachable
HTTPS_PROXY=http://127.0.0.1:1 HTTP_PROXY=http://127.0.0.1:1 \
node -e 'fetch("https://chatgpt.com/backend-api/wham/usage",{signal:AbortSignal.timeout(15000)}).then(r=>console.log("status",r.status)).catch(e=>console.log("ERR",e.cause?.code))'
# -> status 403 (a direct connection was made; in an unblocked region you get 401)
# 2. Same request with a dispatcher wired up: the proxy IS used
HTTPS_PROXY=http://127.0.0.1:1 NODE_USE_ENV_PROXY=1 \
node -e 'fetch("https://chatgpt.com/backend-api/wham/usage",{signal:AbortSignal.timeout(15000)}).then(r=>console.log("status",r.status)).catch(e=>console.log("ERR",e.cause?.code))'
# -> ERR ECONNREFUSED
# 3. For contrast, curl honours the same variable
HTTPS_PROXY=http://127.0.0.1:1 curl --max-time 10 https://chatgpt.com/backend-api/wham/usage
# -> exit 7, connection refusedB. The user-visible symptom, on a network where chatgpt.com / api.anthropic.com / api2.cursor.sh reject the direct IP but the proxy is allowed:
export HTTP_PROXY=http://127.0.0.1:10808 HTTPS_PROXY=http://127.0.0.1:10808
npx bb-app@latest
bb settings usage # or Settings -> Usage limits in the UIDid not reproduce with: the codex CLI itself (it proxies via its own [features.network_proxy] config); loopback traffic to bb's own ports; a clean data dir (unrelated).
Expected vs actual
Actual — bb settings usage, with a working proxy exported and reachable (account emails redacted):
{
"codex": {
"status": "error",
"message": "Codex usage request failed (HTTP 403).",
"planLabel": null,
"accountEmail": "<redacted>"
},
"claude-code": {
"status": "error",
"message": "Claude usage request failed (HTTP 403).",
"planLabel": "Max (5x)",
"accountEmail": "<redacted>"
},
"acp-cursor": {
"status": "error",
"message": "Cursor usage request failed (HTTP 403).",
"planLabel": null,
"accountEmail": null
}
}
Expected: the same usage payload the endpoint returns when the request actually goes through the proxy. With identical credentials and identical headers, curl through that same proxy returns real data:
$ curl -x http://127.0.0.1:10808 -H "Authorization: Bearer $ACCESS_TOKEN" \
-H "chatgpt-account-id: $ACCOUNT_ID" -H "originator: bb" \
-H "User-Agent: bb-provider-codex" -H "Accept: application/json" \
https://chatgpt.com/backend-api/wham/usage
200
{"user_id":"user-…","account_id":"…","email":"…","plan_type":"prolite","rate_limit":{"allowed":…}}
Confirmed the fix at the network layer by replaying bb's exact fetchCodexUsage request from Node with a dispatcher enabled: NODE_USE_ENV_PROXY=1 → HTTP 200, plan_type: prolite, all four rate_limit windows present.
Evidence
Direct vs. proxied, same machine, same moment:
| Endpoint | direct | via proxy |
|---|---|---|
chatgpt.com/backend-api/wham/usage (authenticated) |
403 | 200 + payload |
api.anthropic.com/api/oauth/usage (unauth) |
403 | 429 |
api2.cursor.sh/aiserver.v1.DashboardService/… (unauth) |
403 | 415 |
api.openai.com/v1/models (unauth) |
403 | 401 |
The 403s are edge rejections of the direct IP; every proxied response is a real application-layer response.
Call sites that use bare global fetch and therefore never see the proxy (permalinks at 06aeaa99):
plugins/provider-codex/src/ai/chatgpt-fetch.ts#L109— shared by usage and the subscription request pathplugins/provider-codex/src/bridge/provider-maintenance.ts#L352→ error string at#L361plugins/provider-codex/src/ai/chatgpt-client.ts#L766and#L784— bb's own Responses calls, not routed through thecodexCLIplugins/provider-claude-code/src/bridge/provider-maintenance.ts#L495packages/provider-bridge-acp/src/bridge/provider-maintenance.ts#L360apps/server/src/services/ai/voice-transcription.ts#L226
The one place that gets it right, and the precedent for a fix: plugins/push-notifications/sender.ts#L507 builds an EnvHttpProxyAgent and passes it as a per-request dispatcher. grep for setGlobalDispatcher|ProxyAgent|EnvHttpProxyAgent across apps, packages and plugins returns that file and nothing else outside tests, so no global dispatcher is installed anywhere.
Environment inheritance is not the problem: sanitizeInheritedChildProcessEnv strips only NODE_ENV and BB_*, so the proxy variables do reach the plugin host worker where provider-codex runs. They are simply never read.
Partial workaround, and why it is not enough: exporting NODE_USE_ENV_PROXY=1 before launching bb makes Node honour the variables process-wide. Verified on Node 24.14.1: bb's loopback traffic is unaffected (127.0.0.1:38886 and localhost:38886 health endpoints still return 200, given localhost,127.0.0.1 in NO_PROXY), and the usage request returns 200.
But that flag only exists in Node 24, while bb's baseline is older — package.json declares "node": ">=22.19.0" and .nvmrc pins 22.19.0. On that pinned version the escape hatch is simply absent:
$ npx -y [email protected] --use-env-proxy -e 'console.log("ok")'
node: bad option: --use-env-proxy
$ HTTPS_PROXY=http://127.0.0.1:1 NODE_USE_ENV_PROXY=1 npx -y [email protected] \
-e 'fetch("https://chatgpt.com/backend-api/wham/usage").then(r=>console.log("status",r.status))'
status 403 # variable ignored, request still went direct
So on bb's own supported Node version there is no user-side workaround at all, and the packaged desktop app gives the user no place to set it either.
Suggested fix: install a global undici dispatcher once at server and host-daemon startup, e.g. setGlobalDispatcher(new EnvHttpProxyAgent()) when any proxy variable is set. That covers every current and future fetch call site in one place, keeps NO_PROXY semantics, and works regardless of Node version. Happy to open the PR for this once approved per CONTRIBUTING.md.
What you ruled out
- Not a duplicate of Transcription often fails with HTTP 403 due to cloudflare when using codex subscription #1587 ("Transcription often fails with HTTP 403 due to cloudflare when using codex subscription"). That one is Cloudflare bot mitigation on a direct connection, and the fix for it was the cf-cookie retry in
chatgpt-fetch.ts. Herecf-mitigatedis absent on the 403 and the retry cannot help, because the request never leaves through the proxy at all. - Not a credentials problem: the same access token and headers return
200through the proxy and403direct. - Not environment inheritance: proxy variables are present in
/proc/<pid>/environfor every bb process, and the env sanitizer does not strip them. - Not a
NO_PROXYmisconfiguration: the dead-port repro above shows the proxy is ignored for external hosts even when nothing excludes them. - Not specific to one provider: Codex, Claude and Cursor usage all fail identically, and all three endpoints reject the direct IP.
- Not the provider CLIs:
codexandclaudeproxy correctly on this machine, which is why agent turns keep working while bb's own calls fail. - Still present on
main@06aeaa994942ae7527dc49d2268c1f801e8542a0by code inspection; reproduced at runtime on the matching 0.42.1 release.
Suggested priority and effort
Medium–High — hits every user behind a mandatory proxy: corporate networks, and users in regions where OpenAI/Anthropic reject direct connections, for whom bb's own AI features fail outright. No workaround on bb's declared Node baseline (22.19.0) or on the desktop app; partial one on Node 24. Effort probably Low: one dispatcher installed at two startup paths.
Checks
- I reproduced this on the latest release (0.42.1) and read the code on
main@06aeaa99. - I searched open and closed issues for the same problem.
- This was written by an agent; the body ends with the marker below.
AGENT GENERATED
Activity
dkarelov commentedon Sep 8, 2026
Follow-up findings from prototyping the fix locally. Three of them change what the fix has to look like, so posting them here rather than leaving them implicit.
1. The one-line fix I suggested above is not safe — it would break bb.
setGlobalDispatcher(new EnvHttpProxyAgent())routes everything through the proxy, and bb's own inter-process traffic is HTTP on loopback (launcher → server health checks, server ↔ host daemon, CLI → server). A user who setsHTTP_PROXYwithout listing loopback inNO_PROXY— which is the common case, since nothing today tells them they need to — would have that internal traffic sent to their proxy. Against a dead proxy:Node's own
--use-env-proxybehaves identically, so this is not an undici quirk to route around. Whatever installs the dispatcher should force loopback into the no-proxy set rather than trusting the environment, and preserve a bare*unchanged (undici only honours the wildcard as an exact value, so appending to it silently disables it).2. An IPv6 loopback entry needs its brackets.
undici parses no-proxy entries with
/^(.+):(\d+)$/, so a bare::1becomes hostname:with port1and never matches anything.[::1]is the form that works — matching the bracketed host undici compares against. Worth knowing for anyone who currently has::1inNO_PROXYand assumes it is doing something.3. undici tunnels proxied requests with
CONNECTeven for plainhttp://origins.A test double that is only an HTTP server will hang rather than fail, because it never answers the
CONNECT. This cost me a confusing timeout; noting it so the next person writing a test for this does not repeat it.Where the dispatcher has to go. One installation per process, and there are four processes that make outbound requests, not one:
apps/server— voice transcription, marketplace statsapps/host-daemonplugins/provider-codex/src/host.tsmakes bb's own ChatGPT Responses callsbridge.tsruns the usage requests this issue is aboutOne implementation trap.
apps/host-daemon/src/plugin-host-worker.tscurrently imports nothing butnode:builtins, and it is forked as raw TypeScript (relying on Node's type stripping) in dev and inplugin-host-worker.test.ts. Importing a workspace package whose index re-exports./something.jsbreaks it there withERR_MODULE_NOT_FOUND, because type stripping does not rewrite the extension. A subpath export whose target has no relative imports works; the package root does not.I have a local patch along these lines with tests, but per CONTRIBUTING.md I am not on the approved-contributor list, so I am not opening a PR. Happy to hand it over or to go through the Discord approval step first — whichever the maintainers prefer.
bb-slop-cop commentedon Sep 8, 2026
🚨 SLOP COP 🚨 ·
new-issue-autopilotClassification: Bug · Priority Medium · Effort Low
Labels:
providers,provider-codex,provider-claude-code,provider-acp,confirmed-reproReport: https://get-bb.github.io/reports/issues/3239.html
Verdict: REPRODUCED · Confidence: high
Root cause: bb-owned provider and server request paths call Node's default
fetchwithout a proxy-aware dispatcher. Provider host code also runs in a separately forked process, so parent-process dispatcher state would not cover it.Reproduction: a deterministic local Vitest pointed the proxy variables at a closed loopback port and invoked bb's Codex fetch wrapper; it reached the origin and returned HTTP 200 in both the primary and second clean trusted checkouts.
Pull request: not opened because a complete fix crosses the server and forked plugin-host subsystems and requires deciding proxy-agent dependency ownership, which fails the simple-fix and no-new-dependency gates.
lebryk commentedon Oct 5, 2026
Related, filed separately as #4957: the host daemon's own
wsandnode:http(s)connections (server WebSocket, bb connect tunnel, machine auth proxy) ignore the proxy variables even withNODE_USE_ENV_PROXY=1, so a global dispatcher fix here would not cover them. The prototype linked there always connects loopback directly, in line with your first follow-up finding.One host toolchain for executable discovery, child PATH, and proxy/CA…
ymichael commentedon Nov 17, 2026
Fixed by #6194: the server, daemon and workers now honour
HTTP(S)_PROXY. This needs Node 22.21+ or 24.5+. Closing.