Fix Node.js postinstall.js building from source

This commit is contained in:
Wilson Lin 2023-05-07 17:52:30 +07:00
parent 6021e02648
commit 49ab5efe76
1 changed files with 5 additions and 1 deletions

View File

@ -22,7 +22,11 @@ const fetch = (url) =>
new Promise((resolve, reject) => {
const stream = https.get(url, (resp) => {
if (!resp.statusCode || resp.statusCode < 200 || resp.statusCode > 299) {
return reject(new StatusError(resp.statusCode));
reject(new StatusError(resp.statusCode));
// Destroy stream to allow Node.js to exit.
// Destroy after `reject` in case "error" handler is unintentionally triggered.
resp.destroy();
return;
}
const parts = [];
resp.on("data", (chunk) => parts.push(chunk));