demystify0137's Claude account sits behind a socks5:// proxy. Every turn
was answered 502 after minutes of retries, Claude Code failing each try as
UnsupportedProxyProtocol: it is a Bun binary, and Bun takes only http://
and https:// proxies. magpie handed it the socks5:// URL as HTTPS_PROXY.
Every Claude Code magpie runs for the subscription now gets its env from
one helper, netproxy.EnvForBunWith, which sets the proxy as before and
puts the loopback HTTP bridge (netproxy.Bridge, #1409) in place of a SOCKS
URL: a turn (startRun), the model test (askClaude), /usage (claudeUsage),
sign-in (startClaudeSignIn) and the sign-in check (claudeSignedIn). Where
the bridge can't be used (it doesn't start, or Claude Code runs in WSL
under NAT, which doesn't reach this computer's loopback) the request fails
at once with that reason, instead of Claude Code retrying for minutes.
Other CLIs magpie runs with a proxy (grok, devin, cursor-agent) aren't Bun
(checked their binaries), and the settings.json env writer already leaves
SOCKS out.
What was run:
- Real Claude Code 2.1.302 in a sandbox HOME with a fake API key, through
a fake SOCKS5 proxy (temporary test, removed): raw socks5:// gave "API
Error: Unable to connect to API (UnsupportedProxyProtocol)" with 0
SOCKS connections; bridged it reached Anthropic, 401 "Invalid API key",
7 SOCKS connections.
- New tests TestEnvForBunWithBridgesTheProvidersSOCKS,
TestClaudeCodeGivenTheBridgeForASOCKSProxy (turn, askClaude,
claudeUsage), TestClaudeSignInBridgesASOCKSProxy. With proxied()
put back to EnvWith both gateway and provider tests went red ("Claude
Code was given the SOCKS proxy: https=socks5://127.0.0.1:1...",
"login-proxy: Claude Code ran with HTTPS_PROXY=\"socks5://127.0.0.1:1\"").
- gofmt -l clean; go vet -tags nogui ./... on darwin, GOOS=linux and
GOOS=windows at 8b1fad8f5: ok.
- Full suite at 8b1fad8f5 (this and #2649 on origin/main 9f9bfc160),
-tags nogui -timeout 100m, load ~290: every package ok except three
timing reds outside this change, each green alone with -count=3:
TestBurstTellsNoSpeed (#2719), TestFXStateDoesNotWait (fixed on main since, bad4508c4),
TestTaggedReposSlowRead (#1889). internal/agent passed (3659s); at
-timeout 45m it timed out twice at the earlier base 7660399a1 with no
--- FAIL before the deadline (#2544), and passed alone at 100m (2790s).
- Rebased onto origin/main 17557132c (7 commits, none in these files):
gofmt and vet on all three systems, then internal/gateway,
internal/provider, internal/netproxy and internal/claudebridge at
9af3bb98b: ok. The whole suite wasn't run again at this head.
Not tried: Windows, or Claude Code in WSL (mirrored or NAT).