Skip to content

fix(npm): release HTTPS response stream in postinstall downloadFile (gh#3595)#3618

Open
steveyegge wants to merge 1 commit intomainfrom
polecat/slit-mnwbv17l
Open

fix(npm): release HTTPS response stream in postinstall downloadFile (gh#3595)#3618
steveyegge wants to merge 1 commit intomainfrom
polecat/slit-mnwbv17l

Conversation

@steveyegge
Copy link
Copy Markdown
Collaborator

Summary

Closes the HTTPS response stream in postinstall.js downloadFile() before rename, fixing the file-handle leak that prevented zip extraction on Windows.

Scope

Partial fix for hq-j6hur.6 (install/build breakage). Covers:

  • gh#3595 — npm postinstall file-handle leak (Windows)
  • gh#3451 — brew HEAD gastown on Linux (follow-up)
  • gh#3502 — Docker build (follow-up)

Context

Dispatched by mayor as part of release-gate hq-j6hur. Polecat: gastown/slit.

Opened by mayor because polecat pushed branch but did not open the PR (matches gh#3603, tracked in hq-j6hur.3).

Fixes #3595

…gh#3595)

On Windows, `npm install -g @gastown/gt` fails during the postinstall
ZIP extraction with "The process cannot access the file ... because it
is being used by another process." PowerShell's Expand-Archive cannot
open the ZIP because Node.js still holds a handle to it.

Root cause: downloadFile() pipes the HTTPS response into a write stream
and resolves after file.close(), but never destroys the response. The
readable stream keeps the file handle alive until GC, and Windows
mandatory file locking prevents any other process from opening it in
the meantime. Unix uses advisory locking, so macOS/Linux are unaffected.

Fix: call response.destroy() immediately before resolving on the
success path. The redirect path already cleans up (resume + file.close
+ recurse) and is unchanged.

Closes gh#3595

Refs: hq-j6hur.6
@github-actions github-actions bot added the status/needs-triage Inbox — we haven't looked at it yet label Apr 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status/needs-triage Inbox — we haven't looked at it yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

npm install -g @gastown/gt fails on Windows — postinstall.js file handle leak prevents zip extraction

1 participant