Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mirror-url parameter to allow downloading Node.js from a custom URL #1211

Closed
wants to merge 26 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
error
  • Loading branch information
aparnajyothi-y committed Feb 3, 2025
commit fb3b65568f5a7d366ab85803307ed4fad335862c
21 changes: 19 additions & 2 deletions dist/setup/index.js
Original file line number Diff line number Diff line change
@@ -100158,8 +100158,25 @@ class BaseDistribution {
return __awaiter(this, void 0, void 0, function* () {
const initialUrl = this.getDistributionUrl();
const dataUrl = `${initialUrl}/index.json`;
const response = yield this.httpClient.getJson(dataUrl);
return response.result || [];
try {
const response = yield this.httpClient.getJson(dataUrl);
return response.result || [];
}
catch (err) {
if (err instanceof Error && err.message.includes('getaddrinfo EAI_AGAIN')) {
core.error(`Network error: Failed to resolve the server at ${dataUrl}.
Please check your DNS settings or verify that the URL is correct.`);
}
else if (err instanceof hc.HttpClientError && err.statusCode === 404) {
core.error(`404 Error: Unable to find versions at ${dataUrl}.
Please verify that the mirror URL is valid.`);
}
else {
core.error(`Failed to fetch Node.js versions from ${dataUrl}.
Please check the URL and try again.}`);
}
throw err;
}
});
}
getNodejsDistInfo(version) {
15 changes: 14 additions & 1 deletion src/distributions/base-distribution.ts
Original file line number Diff line number Diff line change
@@ -108,9 +108,22 @@ export default abstract class BaseDistribution {
const initialUrl = this.getDistributionUrl();

const dataUrl = `${initialUrl}/index.json`;

try {
const response = await this.httpClient.getJson<INodeVersion[]>(dataUrl);
return response.result || [];
}catch (err) {
if (err instanceof Error && err.message.includes('getaddrinfo EAI_AGAIN')) {
core.error(`Network error: Failed to resolve the server at ${dataUrl}.
Please check your DNS settings or verify that the URL is correct.`);
} else if (err instanceof hc.HttpClientError && err.statusCode === 404) {
core.error(`404 Error: Unable to find versions at ${dataUrl}.
Please verify that the mirror URL is valid.`);
} else {
core.error(`Failed to fetch Node.js versions from ${dataUrl}.
Please check the URL and try again.}`);
}
throw err;
}
}

protected getNodejsDistInfo(version: string) {
Loading
Oops, something went wrong.