Repository navigation
Fix cold proxy authentication in the desktop HTTP client - #26957
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Merge Risk: 🟡 Moderate · up to With saved proxy credentials, canceled downloads can leave network work running, manual redirects can fail, and callers can lose separate cookie values. Unusually large request payloads may also require substantial temporary memory. These scoped issues warrant correction before merge. Pre-merge checks |
|
33a182d to
19a875e
Compare
There was a problem hiding this comment.
Actionable comments posted: 4
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
55ecc59b-595c-48c1-ac53-e55c9a0e100b
📒 Files selected for processing (4)
config/scripts/vitest-node-runtime-files.mjssrc/main/host/electron-http-client.test.tssrc/main/host/electron-http-client.tssrc/main/host/electron-proxy-login-fetch.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.
| async cancel() { | ||
| await chunks.return?.() | ||
| } |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Abort the native request when the response body is canceled.
If a caller cancels Response.body before the download ends, chunks.return() destroys the incoming stream but does not cancel Electron’s URL loader. A slow or stalled download can therefore retain its native request. Give toWebBody access to native and call native.abort() on cancellation. Electron 43.7.5 cancels the loader through ClientRequest.abort(). (raw.githubusercontent.com)
| request.credentials === 'same-origin' && !origin ? 'include' : request.credentials, | ||
| cache: request.cache, | ||
| referrerPolicy: request.referrerPolicy, | ||
| redirect: request.redirect |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
Handle redirect: 'manual' without canceling the request.
If a caller sets RequestInit.redirect to 'manual', this bridge passes that mode to net.request but installs no redirect handler. Electron 43.7.5 then cancels the redirect and emits an error instead of returning a Fetch response. Preserve the Fetch contract for this mode, or keep these requests on a compatible transport. (raw.githubusercontent.com)
| } | ||
| const headers = new Headers() | ||
| for (const [key, value] of Object.entries(response.headers)) { | ||
| headers.set(key, Array.isArray(value) ? value.join(', ') : value) |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Preserve each Set-Cookie header separately.
If the server returns multiple cookies, Electron supplies response.headers['set-cookie'] as an array. Joining that array and calling headers.set turns separate cookies into one value, so Response.headers.getSetCookie() cannot return the original cookies. Append each Set-Cookie value separately; keep singleton headers on set. The new test at src/main/host/electron-http-client.test.ts Line 122 currently accepts the joined value and should check getSetCookie() instead. (raw.githubusercontent.com)
Based on learnings: “Use headers.append(name, value) for headers that may legitimately have multiple values.”
Source: Learnings
| } else if (native instanceof Writable) { | ||
| void request.body.pipeTo(Writable.toWeb(native)).then(() => native.end(), reject) |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Enable streaming for large native uploads.
If a request has a large body, pipeTo supplies chunks but native.chunkedEncoding remains false. Electron 43.7.5 then concatenates the entire upload in memory before starting the request. Set native.chunkedEncoding = true before the first write for bodies that need streaming, and verify that the destination accepts chunked uploads. (raw.githubusercontent.com)
… cold start (#28411) * fix(usage): usage requests answer authenticated-proxy challenges on a cold start Claude, Cursor, Gemini, Grok, Kimi, OpenCode Go (API key) and MiniMax (API key) usage fetchers called Electron's net.fetch directly, which cancels every proxy login challenge. They now go through the shared desktop HTTP client, which answers the challenge with the configured proxy credentials (#26957), like Codex and ZCode already do. * test(cursor): route the wire fixture through the desktop HTTP client
ELI5
If you set a proxy that needs a username and password in Orca's settings, background requests from the desktop app (Jira, agent status rule updates, downloading the Orca runtime for SSH hosts) could fail with "407 Proxy Authentication Required" even though the password was saved. They now send the saved password when that proxy asks for it.
What Changed
Before: the desktop HTTP client used Electron's built-in fetch. When a password-protected proxy challenged the request, Electron cancelled the challenge, so the request failed unless something else (a browser pane, for example) had already logged in to the proxy.
After: when the default session has saved proxy credentials, HTTP(S) requests go through a small fetch that is built on Electron's lower-level request API and listens for the proxy's challenge. It answers only a challenge that comes from a proxy whose host and port match the saved setting, and only once per request; any other challenge, or a repeat after a rejected password, is cancelled. Before choosing, it waits for a pending proxy setting change to finish so a request at startup sees the credentials. Requests with no saved proxy credentials, and non-HTTP URLs, still use Electron's fetch unchanged.
The credential matching rule is shared with the existing app-level handler (one function instead of two copies).
Why
Electron's fetch creates its request internally and attaches no
loginlistener; the request then cancels every authentication challenge, and the app-wideloginevent never fires for main-process requests. There is no public way to add a listener to that internal request, so the fix mirrors Electron's fetch (about 50 lines) over the public request API with the listener added. Alternatives considered: putting credentials in the proxy URL (Chromium ignores them), sending aProxy-Authorizationheader ourselves (leaks credentials to non-proxy hops), or pre-warming the proxy login with a throwaway request (racy, and does not help a cold POST).Linked Issue
Related to #26477, #19755, #11752 (authenticated proxy reports). Supersedes the larger first version of this PR.
Visual Proof
N/A: no UI change. The behavior is network-level; the unit tests reproduce the cold challenge path and fail on main.
Testing
src/main/host/electron-http-client.test.tsdrives a fake Electron request: it covers answering a matching proxy challenge, cancelling non-proxy, wrong-host and repeated challenges, waiting for a pending proxy policy, body upload and response headers/body, bodyless responses, and abort. Four of its six cases fail on main. The Electron behavior it relies on was confirmed in the shipped Electron 43.7.5 binary (ClientRequestcalls the login callback with no credentials when no listener exists, andfetchWithSessionattaches none). It runs under Node because Electron's main process uses Node streams.AI Disclosure
Review
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
Desktop only: the Node HTTP client used by headless hosts, the remote wire format, and SSH execution are unchanged. Platform-independent (no OS-specific paths). Users without saved proxy credentials take the exact same path as before.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)