Repository navigation
Add kit.updater.setProxy(): update checks and downloads through a proxy - #72
Merged
Merged
Conversation
start() returns updater.setProxy({ proxyRules, proxyBypassRules } | null),
applied to electron-updater's own session (its netSession), which the kit
never makes itself. A proxy set before electron-updater loads is kept and
applied as it loads, before any check; calls apply in order, and a check or
download waits for the one being applied. Each change closes the session's
connections and cancels a download under way, since Chromium lets a request
already being answered finish on its old route, so the download fails and
the Update tab says so; nothing starts again by itself. null goes back to
how the app was launched: the system's settings, or none with
--no-proxy-server, as the tests launch it, so nothing searches for a proxy.
The demo takes one from KIT_DEMO_PROXY (with <-loopback>, for its local
update server). The packaged update spec proves, through a local test proxy,
that every request of a check and a download goes through it, null goes
straight to the server, a proxy on a closed port fails the check with
nothing reaching the server, and a change mid-download fails it, saying so,
with Download Update then going through the new proxy. docs/updates.md
gains Through a Proxy.
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.
kit.start()now returnsupdater: { setProxy(config | null) }. It sends every update check and download through a proxy, on electron-updater's own session (autoUpdater.netSession). The kit never creates that partition itself.{ proxyRules, proxyBypassRules? }as strings, ornull. Anything else throwskit.updater.setProxy(): ….updatesoption).setProxy()on the session, thencloseAllConnections(), then cancels any download under way. Chromium lets a request that's already being answered finish on its old route, so closing connections alone doesn't stop a download (measured in the packaged demo). The download fails and the Update tab says so ("Version x couldn't be downloaded."). Nothing restarts by itself: Download Update tries again through the new proxy.nullgoes back to how the app was launched:{ mode: "system" }, or{ mode: "direct" }when it was launched with--no-proxy-server. Tests launch apps that way throughnetLogSwitches(). Without this,nullmade the packaged demo look upwpadon Windows, and the no-outside-lookups check caught it.KIT_DEMO_PROXY, adding<-loopback>so its local update server goes through the proxy too. It also exposesglobalThis.demoKitso the tests can call it from main.docs/updates.mdgains "Through a Proxy".Tests
test/updater.test.js, 12 new tests:nullgives the system's settings, or direct with--no-proxy-serverstart()'supdater.setProxy()e2e/update-server.spec.js(packaged), through a local test proxy (test/helpers/proxy.js), proves:nullgoes straight to the serverLocally on Windows:
npm testpasses 304 of 304, and the full packaged Playwright suite 175 of 175. The visual images are unchanged.