Commit b905a31
slit
fix(npm): release HTTPS response stream in postinstall downloadFile (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.61 parent 29a006d commit b905a31
1 file changed
+9
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
86 | | - | |
87 | | - | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
88 | 95 | | |
89 | 96 | | |
90 | 97 | | |
| |||
0 commit comments