Files
Chad Piha c4ae6071e8 fix(scripts): let download scripts exit after following a redirect (#2410)
* fix(scripts): let download scripts exit after following a redirect

downloadFile followed redirects without reading the redirect body. On
Node 24 the global agent keeps sockets alive and only frees (and unrefs)
a socket once its response ends, so the unread 302 from huggingface.co
pinned the socket and kept `download-whisper-vad-model.js` alive for
minutes, stalling the `predev:main` chain before Electron started.

Drain redirect bodies in downloadFile and fetchJson, drain fetchJson's
non-200 bodies, and destroy a timed-out fetchJson request instead of only
rejecting.

* fix(scripts): keep a followed redirect from cancelling the live download

downloadFile's error and timeout handlers acted on whichever request was
current, so a reset on a redirect whose body was still draining destroyed
the request that replaced it and forced a retry. Each handler now only acts
on its own request; a stale one that times out is just destroyed.

Also adds a test for fetchJson's timeout closing the stalled request.
2026-09-30 00:16:43 +02:00
..