Merge branch 'main' into fix/graalvm-api-rate-limit

This commit is contained in:
mahabaleshwars 2025-09-09 11:31:10 +05:30
commit 6593b7ea10
9 changed files with 1553 additions and 1489 deletions

View file

@ -1,6 +1,6 @@
--- ---
name: undici name: undici
version: 5.28.5 version: 5.29.0
type: npm type: npm
summary: An HTTP/1.1 client, written from scratch for Node.js summary: An HTTP/1.1 client, written from scratch for Node.js
homepage: https://undici.nodejs.org homepage: https://undici.nodejs.org

File diff suppressed because it is too large Load diff

View file

@ -41,9 +41,7 @@ describe('getAvailableVersions', () => {
expect(availableVersions).not.toBeNull(); expect(availableVersions).not.toBeNull();
const length = const length =
os.platform() === 'win32' os.platform() === 'win32' ? manifestData.length : manifestData.length + 2;
? manifestData.length - 1
: manifestData.length + 1;
expect(availableVersions.length).toBe(length); expect(availableVersions.length).toBe(length);
}, 10_000); }, 10_000);
}); });

38
dist/setup/index.js vendored
View file

@ -129863,6 +129863,7 @@ class JavaBase {
} }
else { else {
core.info('Trying to resolve the latest version from remote'); core.info('Trying to resolve the latest version from remote');
try {
const javaRelease = yield this.findPackageForDownload(this.version); const javaRelease = yield this.findPackageForDownload(this.version);
core.info(`Resolved latest version as ${javaRelease.version}`); core.info(`Resolved latest version as ${javaRelease.version}`);
if ((foundJava === null || foundJava === void 0 ? void 0 : foundJava.version) === javaRelease.version) { if ((foundJava === null || foundJava === void 0 ? void 0 : foundJava.version) === javaRelease.version) {
@ -129874,6 +129875,28 @@ class JavaBase {
core.info(`Java ${foundJava.version} was downloaded`); core.info(`Java ${foundJava.version} was downloaded`);
} }
} }
catch (error) {
if (error instanceof tc.HTTPError) {
if (error.httpStatusCode === 403) {
core.error('HTTP 403: Permission denied or access restricted.');
}
else if (error.httpStatusCode === 429) {
core.warning('HTTP 429: Rate limit exceeded. Please retry later.');
}
else {
core.error(`HTTP ${error.httpStatusCode}: ${error.message}`);
}
}
else {
const message = error instanceof Error ? error.message : JSON.stringify(error);
core.error(`Java setup failed due to network issue or timeout: ${message}`);
}
if (error instanceof Error && error.stack) {
core.debug(error.stack);
}
throw error;
}
}
// JDK folder may contain postfix "Contents/Home" on macOS // JDK folder may contain postfix "Contents/Home" on macOS
const macOSPostfixPath = path_1.default.join(foundJava.path, constants_1.MACOS_JAVA_CONTENT_POSTFIX); const macOSPostfixPath = path_1.default.join(foundJava.path, constants_1.MACOS_JAVA_CONTENT_POSTFIX);
if (process.platform === 'darwin' && fs.existsSync(macOSPostfixPath)) { if (process.platform === 'darwin' && fs.existsSync(macOSPostfixPath)) {
@ -130732,7 +130755,12 @@ class JetBrainsDistribution extends base_installer_1.JavaBase {
// url is identical except page_index so print it once for debug // url is identical except page_index so print it once for debug
core.debug(`Gathering available versions from '${rawUrl}'`); core.debug(`Gathering available versions from '${rawUrl}'`);
} }
const paginationPage = (yield this.http.getJson(rawUrl, requestHeaders)).result; const paginationPageResult = (yield this.http.getJson(rawUrl, requestHeaders)).result;
if (!paginationPageResult || paginationPageResult.length === 0) {
// break infinity loop because we have reached end of pagination
break;
}
const paginationPage = paginationPageResult.filter(version => this.stable ? !version.prerelease : version.prerelease);
if (!paginationPage || paginationPage.length === 0) { if (!paginationPage || paginationPage.length === 0) {
// break infinity loop because we have reached end of pagination // break infinity loop because we have reached end of pagination
break; break;
@ -130740,9 +130768,11 @@ class JetBrainsDistribution extends base_installer_1.JavaBase {
rawVersions.push(...paginationPage); rawVersions.push(...paginationPage);
page_index++; page_index++;
} }
if (this.stable) {
// Add versions not available from the API but are downloadable // Add versions not available from the API but are downloadable
const hidden = ['11_0_10b1145.115', '11_0_11b1341.60']; const hidden = ['11_0_10b1145.115', '11_0_11b1341.60'];
rawVersions.push(...hidden.map(tag => ({ tag_name: tag, name: tag }))); rawVersions.push(...hidden.map(tag => ({ tag_name: tag, name: tag, prerelease: false })));
}
const versions0 = rawVersions.map((v) => __awaiter(this, void 0, void 0, function* () { const versions0 = rawVersions.map((v) => __awaiter(this, void 0, void 0, function* () {
var _a; var _a;
// Release tags look like one of these: // Release tags look like one of these:
@ -130761,7 +130791,7 @@ class JetBrainsDistribution extends base_installer_1.JavaBase {
.replace('-', ''); .replace('-', '');
const vsplit = vstring.split('b'); const vsplit = vstring.split('b');
let semver = vsplit[0]; let semver = vsplit[0];
const build = +vsplit[1]; const build = vsplit[1];
// Normalize semver // Normalize semver
if (!semver.includes('.') && !semver.includes('_')) if (!semver.includes('.') && !semver.includes('_'))
semver = `${semver}.0.0`; semver = `${semver}.0.0`;
@ -131245,7 +131275,7 @@ class MicrosoftDistributions extends base_installer_1.JavaBase {
} }
} }
catch (err) { catch (err) {
core.debug(`Http request for microsoft-openjdk-versions.json failed with status code: ${response === null || response === void 0 ? void 0 : response.statusCode}`); core.debug(`Http request for microsoft-openjdk-versions.json failed with status code: ${response === null || response === void 0 ? void 0 : response.statusCode}. Error: ${err}`);
return null; return null;
} }
if (response.result) { if (response.result) {

View file

@ -40,12 +40,12 @@
"@types/jest": "^29.5.14", "@types/jest": "^29.5.14",
"@types/node": "^20.11.24", "@types/node": "^20.11.24",
"@types/semver": "^7.5.8", "@types/semver": "^7.5.8",
"@typescript-eslint/eslint-plugin": "^5.54.0", "@typescript-eslint/eslint-plugin": "^8.35.1",
"@typescript-eslint/parser": "^5.54.0", "@typescript-eslint/parser": "^8.35.1",
"@vercel/ncc": "^0.38.1", "@vercel/ncc": "^0.38.1",
"eslint": "^8.57.0", "eslint": "^8.57.0",
"eslint-config-prettier": "^8.6.0", "eslint-config-prettier": "^8.6.0",
"eslint-plugin-jest": "^27.9.0", "eslint-plugin-jest": "^29.0.1",
"eslint-plugin-node": "^11.1.0", "eslint-plugin-node": "^11.1.0",
"jest": "^29.7.0", "jest": "^29.7.0",
"jest-circus": "^29.7.0", "jest-circus": "^29.7.0",

View file

@ -51,6 +51,7 @@ export abstract class JavaBase {
core.info(`Resolved Java ${foundJava.version} from tool-cache`); core.info(`Resolved Java ${foundJava.version} from tool-cache`);
} else { } else {
core.info('Trying to resolve the latest version from remote'); core.info('Trying to resolve the latest version from remote');
try {
const javaRelease = await this.findPackageForDownload(this.version); const javaRelease = await this.findPackageForDownload(this.version);
core.info(`Resolved latest version as ${javaRelease.version}`); core.info(`Resolved latest version as ${javaRelease.version}`);
if (foundJava?.version === javaRelease.version) { if (foundJava?.version === javaRelease.version) {
@ -60,6 +61,27 @@ export abstract class JavaBase {
foundJava = await this.downloadTool(javaRelease); foundJava = await this.downloadTool(javaRelease);
core.info(`Java ${foundJava.version} was downloaded`); core.info(`Java ${foundJava.version} was downloaded`);
} }
} catch (error: any) {
if (error instanceof tc.HTTPError) {
if (error.httpStatusCode === 403) {
core.error('HTTP 403: Permission denied or access restricted.');
} else if (error.httpStatusCode === 429) {
core.warning('HTTP 429: Rate limit exceeded. Please retry later.');
} else {
core.error(`HTTP ${error.httpStatusCode}: ${error.message}`);
}
} else {
const message =
error instanceof Error ? error.message : JSON.stringify(error);
core.error(
`Java setup failed due to network issue or timeout: ${message}`
);
}
if (error instanceof Error && error.stack) {
core.debug(error.stack);
}
throw error;
}
} }
// JDK folder may contain postfix "Contents/Home" on macOS // JDK folder may contain postfix "Contents/Home" on macOS

View file

@ -113,9 +113,18 @@ export class JetBrainsDistribution extends JavaBase {
core.debug(`Gathering available versions from '${rawUrl}'`); core.debug(`Gathering available versions from '${rawUrl}'`);
} }
const paginationPage = ( const paginationPageResult = (
await this.http.getJson<IJetBrainsRawVersion[]>(rawUrl, requestHeaders) await this.http.getJson<IJetBrainsRawVersion[]>(rawUrl, requestHeaders)
).result; ).result;
if (!paginationPageResult || paginationPageResult.length === 0) {
// break infinity loop because we have reached end of pagination
break;
}
const paginationPage: IJetBrainsRawVersion[] =
paginationPageResult.filter(version =>
this.stable ? !version.prerelease : version.prerelease
);
if (!paginationPage || paginationPage.length === 0) { if (!paginationPage || paginationPage.length === 0) {
// break infinity loop because we have reached end of pagination // break infinity loop because we have reached end of pagination
break; break;
@ -125,9 +134,13 @@ export class JetBrainsDistribution extends JavaBase {
page_index++; page_index++;
} }
if (this.stable) {
// Add versions not available from the API but are downloadable // Add versions not available from the API but are downloadable
const hidden = ['11_0_10b1145.115', '11_0_11b1341.60']; const hidden = ['11_0_10b1145.115', '11_0_11b1341.60'];
rawVersions.push(...hidden.map(tag => ({tag_name: tag, name: tag}))); rawVersions.push(
...hidden.map(tag => ({tag_name: tag, name: tag, prerelease: false}))
);
}
const versions0 = rawVersions.map(async v => { const versions0 = rawVersions.map(async v => {
// Release tags look like one of these: // Release tags look like one of these:
@ -148,7 +161,7 @@ export class JetBrainsDistribution extends JavaBase {
const vsplit = vstring.split('b'); const vsplit = vstring.split('b');
let semver = vsplit[0]; let semver = vsplit[0];
const build = +vsplit[1]; const build = vsplit[1];
// Normalize semver // Normalize semver
if (!semver.includes('.') && !semver.includes('_')) if (!semver.includes('.') && !semver.includes('_'))

View file

@ -3,11 +3,12 @@
export interface IJetBrainsRawVersion { export interface IJetBrainsRawVersion {
tag_name: string; tag_name: string;
name: string; name: string;
prerelease: boolean;
} }
export interface IJetBrainsVersion { export interface IJetBrainsVersion {
tag_name: string; tag_name: string;
semver: string; semver: string;
build: number; build: string;
url: string; url: string;
} }

View file

@ -116,7 +116,7 @@ export class MicrosoftDistributions extends JavaBase {
} }
} catch (err) { } catch (err) {
core.debug( core.debug(
`Http request for microsoft-openjdk-versions.json failed with status code: ${response?.statusCode}` `Http request for microsoft-openjdk-versions.json failed with status code: ${response?.statusCode}. Error: ${err}`
); );
return null; return null;
} }