Repository navigation
fix(updater): stop release HEAD probes from crashing main behind an authenticating proxy - #48556
Conversation
…uthenticating proxy Behind a proxy that answers CONNECT with 407, Electron delivers the 407 as a response and then destroys it with net::ERR_TUNNEL_CONNECTION_FAILED. The stable-release HEAD probe settled on that response without reading it or listening for its errors, and the asset probes used net.fetch HEAD, which leaves its response the same way, so the startup update check quit the app. Route every release HEAD through one net.request helper (requestReleaseHead) that aborts the request once the status is known, using manual redirects for GitHub release assets and followed redirects for other asset URLs. Fixes #47027 Co-authored-by: Claude <[email protected]>
|
No actionable comments were generated in the recent review. Walkthrough
Severity of issue fixed: Medium Merge Risk:
|
…uthenticating proxy (#48556) Behind a proxy that answers CONNECT with 407, Electron delivers the 407 as a response and then destroys it with net::ERR_TUNNEL_CONNECTION_FAILED. The stable-release HEAD probe settled on that response without reading it or listening for its errors, and the asset probes used net.fetch HEAD, which leaves its response the same way, so the startup update check quit the app. Route every release HEAD through one net.request helper (requestReleaseHead) that aborts the request once the status is known, using manual redirects for GitHub release assets and followed redirects for other asset URLs. Fixes #47027 Co-authored-by: Claude <[email protected]>
ELI5
When Orca starts it quietly asks GitHub whether a newer release exists. On networks whose proxy asks for a password (a
407reply), Electron reported that reply and then threw a second error on it. Nothing in Orca was listening for that second error, so the whole app quit about a second after launch. Now Orca reads the status and closes the request right away, so the late error never arrives and the app keeps running.What Changed
CONNECTwith407 Proxy Authentication Required, the startup update check crashed the main process with an uncaughtnet::ERR_TUNNEL_CONNECTION_FAILED, and Orca exited shortly after the window appeared.How it works: with a
407, Electron first emits aresponseand then destroys that response withnet::ERR_TUNNEL_CONNECTION_FAILED. Two probes insrc/main/updater/releases/left that response unread and with no error listener:requestGitHubReleaseHead(the stable-releaseHEAD) settled on the response but never released it.net.fetchHEAD, which leaves its response the same way.Both now go through a single
net.requesthelper,requestReleaseHead(url, redirect). It callsrequest.abort()as soon as it has the status code. GitHub release assets keepredirect: 'manual', because the redirect proves the asset exists without fetching the signed storage URL. Other asset URLs useredirect: 'follow', which matches the oldnet.fetchbehaviour. The readiness mapping is now shared: 404 means not-ready, 2xx or a manual 3xx means ready, and anything else means unavailable.Why
The crash comes from an error event on a response object that our code never subscribes to. The cleanest fix is to stop holding that response at all once we have its status. A
HEADprobe has no body we need. We rejected two alternatives:uncaughtExceptionswallow would hide real bugs.errorlistener tonet.fetch's response is not possible, because that response is internal.Handling the
apploginevent for proxy credentials, as the issue suggests, would be a separate feature. This PR only stops the crash.Linked Issue
Fixes #47027
Visual Proof
N/A: there is no UI change. The bug is a main-process crash with no visible state besides the app quitting. Behavioural evidence from a real Electron run is in Testing below.
Testing
Repro and verification were done on macOS (remote M-series Mac, Electron 43.8.10). A harness loaded the old and new
updater-release-readiness/updater-prerelease-feedmodules into a background Electron main process. A local proxy answeredCONNECTwith407, or acted as a MITM for the GitHub host while returning407for the redirect target:HEAD,fetchLatestStableReleaseTag, manifest readiness)ERR_TUNNEL_CONNECTION_FAILED, exit=1null/unavailable302tov1.4.274, manifest readyA control run confirmed that raw
net.fetchHEADstill throws the uncaught error behind a 407 proxy. That is why the asset probe no longer uses it.Local checks:
vitest run src/main/updaterpassed. One unrelatedserve-update-handofftest timed out under load and passed when run alone. The other local checks were oxlint, oxfmt, the anti-slop and code-quality native plugins, ast-grep and the changed-code quality gate.No unit test was added. The failure only shows up in Electron's real network stack, where the loader emits an error after the response, so a mocked
netwould only assert our own stub. The Electron harness above covers it.Performance
None. This runs only during the background update check at startup and on its normal schedule, not on a hot path. The number of requests is unchanged and there is no new sync I/O. Aborting after the status arrives releases each request earlier. Measured over a direct connection on the same Mac: stable
HEADtook 92/26/28 ms new vs 210/27/23 ms old, and manifest readiness took 128/74/77 ms new vs 143/64/67 ms old, which is within network noise.Risk
The riskiest part is that non-GitHub asset URLs moved from
net.fetchtonet.requestwithredirect: 'follow'. If a CDN behaved differently under that request, readiness could come backunavailable. That would only defer an update offer, and it cannot crash the app. A plain revert backs this out.Level: Low
Review
Agent skill upstream boundary
Notes
Cross-platform: the change uses only Electron
netand is the same on macOS, Windows and Linux. The Windows asset path was exercised in the harness. There is no SSH, remote or mobile impact.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)Reported by @Mahmoud-Shereif