Skip to content

Commit b91e907

Browse files
authored
🐛 Update fetch method downstream (#27)
prebuild.js failed during build with UND_ERR_ABORTED when downloading from Red Hat CDN in corporate environments with HTTP/2 restrictions. Root Cause Used 15-year-old https.get() API which poorly handles: - HTTP/2 protocol negotiation - Corporate proxies - Modern network environments konveyor#1030
1 parent c332c41 commit b91e907

File tree

1 file changed

+5
-16
lines changed

1 file changed

+5
-16
lines changed

scripts/prebuild.js

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import fs from "fs";
44
import path from "path";
5-
import https from "https";
65
import { fileURLToPath } from "url";
76

87
const __filename = fileURLToPath(import.meta.url);
@@ -45,21 +44,11 @@ const PLATFORM_BINARY_NAMES = {
4544
};
4645

4746
async function fetchText(url) {
48-
return new Promise((resolve, reject) => {
49-
https
50-
.get(url, (res) => {
51-
let data = "";
52-
res.on("data", (chunk) => (data += chunk));
53-
res.on("end", () => {
54-
if (res.statusCode === 200) {
55-
resolve(data);
56-
} else {
57-
reject(new Error(`HTTP ${res.statusCode}: ${res.statusMessage}`));
58-
}
59-
});
60-
})
61-
.on("error", reject);
62-
});
47+
const response = await fetch(url);
48+
if (!response.ok) {
49+
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
50+
}
51+
return await response.text();
6352
}
6453

6554
try {

0 commit comments

Comments
 (0)