Repository navigation
fix(rate-limits): route Claude OAuth usage fetch through HTTP proxy - #803
Merged
Jinwoo-H merged 2 commits intoApr 19, 2026
Merged
Conversation
Node's built-in fetch (undici) does not honor HTTP_PROXY / HTTPS_PROXY envvars unless a dispatcher is passed explicitly. Users in regions where api.anthropic.com is only reachable via proxy saw the usage indicator silently fail, and — more importantly — Orca was hitting Anthropic from an unexpected IP, which can trip anti-abuse / rate-limit signals on the user's OAuth account. Adds resolveProxyDispatcher() that reads HTTPS_PROXY / ALL_PROXY / HTTP_PROXY (upper and lower case) and attaches an undici ProxyAgent to the usage fetch. Invalid proxy URLs degrade to direct connection rather than crashing polling, since the usage bar is cosmetic. Follow-up (not in this PR): a Settings UI field to configure the proxy for users whose proxy lives in a GUI proxy app (Shadowrocket, Clash) rather than shell envvars. Fixes stablyai#521 Fixes stablyai#800
This was referenced Apr 18, 2026
Replace undici dependency with Electron's net.fetch and bridge env var proxies via session.defaultSession.setProxy(). This aligns with the existing codebase pattern (updater, changelog, feedback all use net.fetch) and covers both OS-level proxy and env var proxy users without adding a new dependency.
Contributor
|
Thanks for the PR! I pushed a commit that swaps the approach slightly: instead of adding |
enrick-dev
pushed a commit
to enrick-dev/orca
that referenced
this pull request
Oct 15, 2026
…tablyai#803) Co-authored-by: Jinwoo-H <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Node's built-in
fetch(undici) does not honorHTTP_PROXY/HTTPS_PROXY/ALL_PROXYenvvars unless adispatcheris passed explicitly. Users in regions whereapi.anthropic.comis only reachable via proxy saw two problems:src/main/rate-limits/claude-fetcher.tsnow resolves a proxy dispatcher from standard envvars and attaches it to the OAuth usage fetch.Changes
resolveProxyDispatcher(env)that reads, in precedence order:HTTPS_PROXY→https_proxy→ALL_PROXY→all_proxy→HTTP_PROXY→http_proxyfetchViaOAuth().undicias an explicit dependency (it is already shipped with Node ≥18 / Electron; adding it lets usimport { ProxyAgent } from 'undici'with types).Fixes
Follow-up (not in this PR)
Some users (e.g. #521 reporter with Shadowrocket, or Clash users on macOS) run their proxy as a GUI app and don't export envvars from a shell — a GUI-launched Orca won't inherit those envvars even if
.zshrchas them. A Settings UI proxy field (overriding envvars when set) would close this gap. I'm happy to submit that as a follow-up PR once this lands — it's a larger change (settings schema + preferences store + form) and splitting keeps review scope tight.Test Plan
pnpm typecheck:nodepassespnpm exec vitest run src/main/rate-limits/claude-fetcher.test.ts— 6/6 greenpnpm exec vitest run src/main/rate-limits/— 10/10 green (no regression)pnpm exec oxlint src/main/rate-limits/claude-fetcher.{ts,test.ts}— 0 warnings / 0 errorsManual verification by end user (me) once a release build is available:
HTTPS_PROXY=http://127.0.0.1:7890before launching Orca; usage bar should load.🤖 Generated with Claude Code