Skip to content

Commit 25fa623

Browse files
authored
chore: report URL on fetchUrlStream error message (#261)
1 parent aa3cbdb commit 25fa623

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

sources/httpUtils.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ export async function fetchUrlStream(url: string, options: RequestOptions = {})
1414

1515
return new Promise<IncomingMessage>((resolve, reject) => {
1616
const request = https.get(url, {...options, agent: proxyAgent}, response => {
17-
const statusCode = response.statusCode ?? 500;
18-
if (!(statusCode >= 200 && statusCode < 300))
19-
return reject(new Error(`Server answered with HTTP ${statusCode}`));
17+
const statusCode = response.statusCode;
18+
if (statusCode != null && statusCode >= 200 && statusCode < 300)
19+
return resolve(response);
2020

21-
return resolve(response);
21+
return reject(new Error(`Server answered with HTTP ${statusCode} when performing the request to ${url}; for troubleshooting help, see https://github.com/nodejs/corepack#troubleshooting`));
2222
});
2323

2424
request.on(`error`, err => {

0 commit comments

Comments
 (0)