Skip to content

Fix cold proxy authentication in the desktop HTTP client - #26957

Merged
OrcaWin merged 2 commits into
mainfrom
nwparker/reproducible-http-proxy-auth-10-09
Oct 11, 2026
Merged

OrcaWin merged 2 commits into
mainfrom
nwparker/reproducible-http-proxy-auth-10-09

Conversation

@nwparker

@nwparker nwparker commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​189 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​189
Prod 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​174 $\color{#cf222e}{\Huge{\mathbf{−}}}$​8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​166

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 login listener; the request then cancels every authentication challenge, and the app-wide login event 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 a Proxy-Authorization header 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

  • I manually tested these changes locally
  • Automated tests added/updated

src/main/host/electron-http-client.test.ts drives 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 (ClientRequest calls the login callback with no credentials when no listener exists, and fetchWithSession attaches none). It runs under Node because Electron's main process uses Node streams.

AI Disclosure

Review

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and 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

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@nwparker
nwparker marked this pull request as ready for review October 9, 2026 20:57
@coderabbitai

coderabbitai Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 38d3307a-7425-41ab-b29d-d7298994d0d7


📥 Commits

Reviewing files that changed from the base of the PR and between 19a875e and eaba65a.



📒 Files selected for processing (2)
  • src/main/host/electron-http-client.test.ts
  • src/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; 1 remain after this review.




📝 Walkthrough
📝 Walkthrough

Walkthrough

The Electron HTTP client now uses Electron’s request API for HTTP and HTTPS requests when proxy credentials are configured and proxy settings are ready. Other requests use net.fetch. The request path handles matching proxy challenges, maps Fetch options and headers, streams bodies, and propagates aborts. New tests cover dispatch, challenge handling, readiness, response behavior, and cancellation.



Priority: ➖ Normal

Merge Risk: 🟡 Moderate · up to eaba6

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 | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 21.43% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 14 functions across 7 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Title check Passed The title clearly and concisely identifies the main change: fixing proxy authentication for cold requests in the desktop HTTP client.
Description check Passed The description is mostly complete. It explains the user impact, implementation, rationale, linked issues, testing, scope, and checklist items. It correctly marks visual proof as not applicable and do…

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR



  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@OrcaWin
OrcaWin force-pushed the nwparker/reproducible-http-proxy-auth-10-09 branch from 33a182d to 19a875e Compare October 11, 2026 07:40

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 55ecc59b-595c-48c1-ac53-e55c9a0e100b
📥 Commits

Reviewing files that changed from the base of the PR and between 33a182d and 19a875e.

📒 Files selected for processing (4)
  • config/scripts/vitest-node-runtime-files.mjs
  • src/main/host/electron-http-client.test.ts
  • src/main/host/electron-http-client.ts
  • src/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.

Comment on lines +19 to +21
async cancel() {
await chunks.return?.()
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ 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

Comment on lines +108 to +109
} else if (native instanceof Writable) {
void request.body.pipeTo(Writable.toWeb(native)).then(() => native.end(), reject)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 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)

@OrcaWin
OrcaWin merged commit 57452c6 into main Oct 11, 2026
49 of 51 checks passed
Jinwoo-H added a commit that referenced this pull request Oct 14, 2026
… 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants