-
Notifications
You must be signed in to change notification settings - Fork 110
fix: proxy ESM loading, progress bar suppression, and temp directory handling #375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
MarshallOfSound
merged 9 commits into
main
from
claude/identify-bugs-failing-tests-ymmHx
Mar 25, 2026
+209
−16
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d798f80
test: add failing tests documenting identified bugs
claude fa6704a
fix: use createRequire to load global-agent in ESM context
claude 26771be
fix: correct progress bar suppression condition
claude 60be031
fix: clear progress timer on download failure
claude 5ff0f00
fix: propagate tempDirectory to SHASUMS256.txt download
claude 4cbf1ae
fix: always clean up validateArtifact temp directory
claude 78f5b38
refactor: replace deprecated url.parse with WHATWG URL
claude b7f983d
test: reorganize new tests into appropriately named files
claude e2a6e91
test: add stable cache-key fixture for real download URL
claude File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| import fs from 'graceful-fs'; | ||
| import os from 'node:os'; | ||
| import path from 'node:path'; | ||
|
|
||
| import { PathLike } from 'node:fs'; | ||
| import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; | ||
|
|
||
| import { GotDownloader } from '../src/GotDownloader'; | ||
|
|
||
| async function flushMicrotasks(): Promise<void> { | ||
| for (let i = 0; i < 10; i++) { | ||
| await Promise.resolve(); | ||
| } | ||
| } | ||
|
|
||
| describe('GotDownloader', () => { | ||
| let tmpDir: string; | ||
|
|
||
| beforeEach(async () => { | ||
| tmpDir = await fs.promises.mkdtemp(path.resolve(os.tmpdir(), 'got-spec-')); | ||
| }); | ||
|
|
||
| afterEach(async () => { | ||
| await fs.promises.rm(tmpDir, { recursive: true, force: true }); | ||
| delete process.env.ELECTRON_GET_NO_PROGRESS; | ||
| vi.useRealTimers(); | ||
| vi.restoreAllMocks(); | ||
| }); | ||
|
|
||
| describe('progress bar suppression', () => { | ||
| it('should not schedule a progress bar timer when quiet: true', async () => { | ||
| vi.spyOn(fs.promises, 'mkdir').mockResolvedValue(undefined); | ||
| vi.useFakeTimers(); | ||
|
|
||
| const downloader = new GotDownloader(); | ||
| const target = path.resolve(tmpDir, 'out.txt'); | ||
|
|
||
| const p = downloader.download('http://127.0.0.1:1/nope', target, { quiet: true }); | ||
| p.catch(() => { | ||
| /* ignore */ | ||
| }); | ||
|
|
||
| await flushMicrotasks(); | ||
|
|
||
| expect(vi.getTimerCount()).toBe(0); | ||
|
|
||
| vi.useRealTimers(); | ||
| await p.catch(() => { | ||
| /* ignore */ | ||
| }); | ||
| }); | ||
|
|
||
| it('should not schedule a progress bar timer when ELECTRON_GET_NO_PROGRESS is set', async () => { | ||
| process.env.ELECTRON_GET_NO_PROGRESS = '1'; | ||
| vi.spyOn(fs.promises, 'mkdir').mockResolvedValue(undefined); | ||
| vi.useFakeTimers(); | ||
|
|
||
| const downloader = new GotDownloader(); | ||
| const target = path.resolve(tmpDir, 'out.txt'); | ||
|
|
||
| const p = downloader.download('http://127.0.0.1:1/nope', target); | ||
| p.catch(() => { | ||
| /* ignore */ | ||
| }); | ||
|
|
||
| await flushMicrotasks(); | ||
|
|
||
| expect(vi.getTimerCount()).toBe(0); | ||
|
|
||
| vi.useRealTimers(); | ||
| await p.catch(() => { | ||
| /* ignore */ | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
| describe('timer cleanup', () => { | ||
| it('should clear the progress timer even when the download fails', async () => { | ||
| vi.spyOn(fs.promises, 'mkdir').mockResolvedValue(undefined); | ||
|
|
||
| const realCreateWriteStream = fs.createWriteStream; | ||
| vi.spyOn(fs, 'createWriteStream').mockImplementationOnce((p: PathLike) => { | ||
| const stream = realCreateWriteStream(p); | ||
| setImmediate(() => stream.emit('error', new Error('boom'))); | ||
| return stream; | ||
| }); | ||
|
|
||
| vi.useFakeTimers({ toFake: ['setTimeout', 'clearTimeout'] }); | ||
|
|
||
| const downloader = new GotDownloader(); | ||
| const target = path.resolve(tmpDir, 'out.txt'); | ||
|
|
||
| await expect(downloader.download('http://127.0.0.1:1/nope', target)).rejects.toThrow(); | ||
|
|
||
| expect(vi.getTimerCount()).toBe(0); | ||
|
|
||
| vi.clearAllTimers(); | ||
| }); | ||
| }); | ||
| }); |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import fs from 'graceful-fs'; | ||
| import path from 'node:path'; | ||
|
|
||
| import { describe, expect, it } from 'vitest'; | ||
|
|
||
| describe('initializeProxy', () => { | ||
| // `require` is not defined in ESM modules. vitest injects a shim, so the | ||
| // runtime failure only manifests when running the built package under | ||
| // plain Node.js. Guard against regressions by checking the source uses | ||
| // createRequire(import.meta.url) to define require before calling it. | ||
| it('defines require via createRequire before using it', () => { | ||
| const source = fs.readFileSync(path.resolve(__dirname, '../src/proxy.ts'), 'utf8'); | ||
| expect(source).toMatch(/createRequire\s*\(\s*import\.meta\.url\s*\)/); | ||
| }); | ||
| }); |
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.
Uh oh!
There was an error while loading. Please reload this page.