Tags: electron/get
Tags
feat!: replace got with native fetch as default downloader (#376) BREAKING CHANGE: The default downloader now uses the built-in Fetch API instead of the got package. The GotDownloader and GotDownloaderOptions exports have been removed; use FetchDownloader and FetchDownloaderOptions instead. Download options now accept RequestInit options instead of got options. The initializeProxy() function now uses undici's EnvHttpProxyAgent instead of global-agent, reading HTTP_PROXY/HTTPS_PROXY/NO_PROXY environment variables directly (GLOBAL_AGENT_* prefixed variables are no longer supported). Co-authored-by: Claude <noreply@anthropic.com>
fix: proxy ESM loading, progress bar suppression, and temp directory … …handling (#375) * test: add failing tests documenting identified bugs Adds test/bugs.spec.ts with 6 failing tests that demonstrate 5 bugs: 1. GotDownloader progress bar suppression uses || instead of &&, so neither quiet:true nor ELECTRON_GET_NO_PROGRESS alone suppresses the progress bar (src/GotDownloader.ts:52). 2. GotDownloader leaks its 30s progress timer when a download fails because clearTimeout is not in a finally block (src/GotDownloader.ts:79-91). 3. initializeProxy() calls require() which is undefined in ESM, silently breaking proxy support (src/proxy.ts:36). 4. validateArtifact() does not forward tempDirectory to the nested SHASUMS256.txt download, so checksums are written to os.tmpdir() regardless of user config (src/index.ts:77-88). 5. validateArtifact() leaks an empty temp directory when cacheMode is ReadOnly/Bypass and checksums are not provided, because the cleanup finally deletes the wrong directory (src/index.ts:111-120). * fix: use createRequire to load global-agent in ESM context The package is published as ESM ("type": "module"), so bare require() is undefined at runtime. The try/catch swallowed the ReferenceError, causing proxy support to silently never work. Define require via createRequire(import.meta.url) so the optional dependency can be loaded synchronously as before. * fix: correct progress bar suppression condition The condition used || instead of &&, so neither `quiet: true` alone nor ELECTRON_GET_NO_PROGRESS alone suppressed the progress bar. Both had to be set simultaneously, contradicting the documented behavior. * fix: clear progress timer on download failure If pipeline() threw, the 30-second progress-bar timer was never cleared and would fire after the download had already failed, rendering a progress bar for a dead download. Move the cleanup into a finally block. * fix: propagate tempDirectory to SHASUMS256.txt download The nested downloadArtifact call for checksum validation forwarded most options but omitted tempDirectory, so SHASUMS256.txt was always written under os.tmpdir() regardless of the caller's configuration. This breaks setups where os.tmpdir() is read-only or on a different filesystem. * fix: always clean up validateArtifact temp directory validateArtifact created its temp directory with ORPHAN mode when the caller owned the output (ReadOnly/Bypass cache modes), but the validation tempFolder never needs to outlive the function. When checksums were not provided, the inner finally block deleted the SHASUMS256 download directory instead, leaving an empty electron-download-* directory behind on every ReadOnly/Bypass download. Always use CLEAN mode for the validation tempFolder. * refactor: replace deprecated url.parse with WHATWG URL url.parse() and url.format() (legacy) are deprecated since Node.js 11. Switch to the WHATWG URL API. The new implementation produces identical cache-directory hashes for all real-world Electron download URLs (verified against github.com, nightlies, ports, and userinfo). Only the synthetic test fixture URL with no path component hashes differently, so the hardcoded expected hash in Cache.spec.ts is updated. * test: reorganize new tests into appropriately named files Split the tests from bugs.spec.ts into: - test/GotDownloader.spec.ts (progress bar and timer cleanup) - test/proxy.spec.ts (createRequire guard) - test/index.spec.ts (tempDirectory handling, added to existing downloadArtifact describe block) * test: add stable cache-key fixture for real download URL Lock in the cache-directory hash for a real Electron release URL so any future URL-parsing change that would invalidate on-disk caches fails this test instead of silently shipping. --------- Co-authored-by: Claude <noreply@anthropic.com>
PreviousNext