diff --git a/dist/post_run/index.js b/dist/post_run/index.js index 3e6009d..3451bd3 100644 --- a/dist/post_run/index.js +++ b/dist/post_run/index.js @@ -2398,6 +2398,18 @@ class CacheServiceClient { } errorMessage = `${errorMessage}: ${body.msg}`; } + // Handle rate limiting - don't retry, just warn and exit + // For more info, see https://docs.github.com/en/actions/reference/limits + if (statusCode === http_client_1.HttpCodes.TooManyRequests) { + const retryAfterHeader = response.message.headers['retry-after']; + if (retryAfterHeader) { + const parsedSeconds = parseInt(retryAfterHeader, 10); + if (!isNaN(parsedSeconds) && parsedSeconds > 0) { + (0, core_1.warning)(`You've hit a rate limit, your rate limit will reset in ${parsedSeconds} seconds`); + } + } + throw new errors_1.RateLimitError(`Rate limited: ${errorMessage}`); + } } catch (error) { if (error instanceof SyntaxError) { @@ -2406,6 +2418,9 @@ class CacheServiceClient { if (error instanceof errors_1.UsageError) { throw error; } + if (error instanceof errors_1.RateLimitError) { + throw error; + } if (errors_1.NetworkError.isNetworkErrorCode(error === null || error === void 0 ? void 0 : error.code)) { throw new errors_1.NetworkError(error === null || error === void 0 ? void 0 : error.code); } @@ -2438,8 +2453,7 @@ class CacheServiceClient { http_client_1.HttpCodes.BadGateway, http_client_1.HttpCodes.GatewayTimeout, http_client_1.HttpCodes.InternalServerError, - http_client_1.HttpCodes.ServiceUnavailable, - http_client_1.HttpCodes.TooManyRequests + http_client_1.HttpCodes.ServiceUnavailable ]; return retryableStatusCodes.includes(statusCode); } @@ -2475,7 +2489,7 @@ function internalCacheTwirpClient(options) { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.UsageError = exports.NetworkError = exports.GHESNotSupportedError = exports.CacheNotFoundError = exports.InvalidResponseError = exports.FilesNotFoundError = void 0; +exports.RateLimitError = exports.UsageError = exports.NetworkError = exports.GHESNotSupportedError = exports.CacheNotFoundError = exports.InvalidResponseError = exports.FilesNotFoundError = void 0; class FilesNotFoundError extends Error { constructor(files = []) { let message = 'No files were found to upload'; @@ -2542,6 +2556,13 @@ UsageError.isUsageErrorMessage = (msg) => { return false; return msg.includes('insufficient usage'); }; +class RateLimitError extends Error { + constructor(message) { + super(message); + this.name = 'RateLimitError'; + } +} +exports.RateLimitError = RateLimitError; //# sourceMappingURL=errors.js.map /***/ }), @@ -106076,7 +106097,7 @@ exports.visitAsync = visitAsync; /***/ ((module) => { "use strict"; -module.exports = /*#__PURE__*/JSON.parse('{"name":"@actions/cache","version":"5.0.2","preview":true,"description":"Actions cache lib","keywords":["github","actions","cache"],"homepage":"https://github.com/actions/toolkit/tree/main/packages/cache","license":"MIT","main":"lib/cache.js","types":"lib/cache.d.ts","directories":{"lib":"lib","test":"__tests__"},"files":["lib","!.DS_Store"],"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/actions/toolkit.git","directory":"packages/cache"},"scripts":{"audit-moderate":"npm install && npm audit --json --audit-level=moderate > audit.json","test":"echo \\"Error: run tests from root\\" && exit 1","tsc":"tsc"},"bugs":{"url":"https://github.com/actions/toolkit/issues"},"dependencies":{"@actions/core":"^2.0.0","@actions/exec":"^2.0.0","@actions/glob":"^0.5.0","@protobuf-ts/runtime-rpc":"^2.11.1","@actions/http-client":"^3.0.1","@actions/io":"^2.0.0","@azure/abort-controller":"^1.1.0","@azure/core-rest-pipeline":"^1.22.0","@azure/storage-blob":"^12.29.1","semver":"^6.3.1"},"devDependencies":{"@types/node":"^24.1.0","@types/semver":"^6.0.0","@protobuf-ts/plugin":"^2.9.4","typescript":"^5.2.2"},"overrides":{"uri-js":"npm:uri-js-replace@^1.0.1","node-fetch":"^3.3.2"}}'); +module.exports = /*#__PURE__*/JSON.parse('{"name":"@actions/cache","version":"5.0.3","preview":true,"description":"Actions cache lib","keywords":["github","actions","cache"],"homepage":"https://github.com/actions/toolkit/tree/main/packages/cache","license":"MIT","main":"lib/cache.js","types":"lib/cache.d.ts","directories":{"lib":"lib","test":"__tests__"},"files":["lib","!.DS_Store"],"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/actions/toolkit.git","directory":"packages/cache"},"scripts":{"audit-moderate":"npm install && npm audit --json --audit-level=moderate > audit.json","test":"echo \\"Error: run tests from root\\" && exit 1","tsc":"tsc"},"bugs":{"url":"https://github.com/actions/toolkit/issues"},"dependencies":{"@actions/core":"^2.0.0","@actions/exec":"^2.0.0","@actions/glob":"^0.5.0","@protobuf-ts/runtime-rpc":"^2.11.1","@actions/http-client":"^3.0.1","@actions/io":"^2.0.0","@azure/abort-controller":"^1.1.0","@azure/core-rest-pipeline":"^1.22.0","@azure/storage-blob":"^12.29.1","semver":"^6.3.1"},"devDependencies":{"@types/node":"^24.1.0","@types/semver":"^6.0.0","@protobuf-ts/plugin":"^2.9.4","typescript":"^5.2.2"},"overrides":{"uri-js":"npm:uri-js-replace@^1.0.1","node-fetch":"^3.3.2"}}'); /***/ }) diff --git a/dist/run/index.js b/dist/run/index.js index c06bff0..87697b5 100644 --- a/dist/run/index.js +++ b/dist/run/index.js @@ -2398,6 +2398,18 @@ class CacheServiceClient { } errorMessage = `${errorMessage}: ${body.msg}`; } + // Handle rate limiting - don't retry, just warn and exit + // For more info, see https://docs.github.com/en/actions/reference/limits + if (statusCode === http_client_1.HttpCodes.TooManyRequests) { + const retryAfterHeader = response.message.headers['retry-after']; + if (retryAfterHeader) { + const parsedSeconds = parseInt(retryAfterHeader, 10); + if (!isNaN(parsedSeconds) && parsedSeconds > 0) { + (0, core_1.warning)(`You've hit a rate limit, your rate limit will reset in ${parsedSeconds} seconds`); + } + } + throw new errors_1.RateLimitError(`Rate limited: ${errorMessage}`); + } } catch (error) { if (error instanceof SyntaxError) { @@ -2406,6 +2418,9 @@ class CacheServiceClient { if (error instanceof errors_1.UsageError) { throw error; } + if (error instanceof errors_1.RateLimitError) { + throw error; + } if (errors_1.NetworkError.isNetworkErrorCode(error === null || error === void 0 ? void 0 : error.code)) { throw new errors_1.NetworkError(error === null || error === void 0 ? void 0 : error.code); } @@ -2438,8 +2453,7 @@ class CacheServiceClient { http_client_1.HttpCodes.BadGateway, http_client_1.HttpCodes.GatewayTimeout, http_client_1.HttpCodes.InternalServerError, - http_client_1.HttpCodes.ServiceUnavailable, - http_client_1.HttpCodes.TooManyRequests + http_client_1.HttpCodes.ServiceUnavailable ]; return retryableStatusCodes.includes(statusCode); } @@ -2475,7 +2489,7 @@ function internalCacheTwirpClient(options) { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.UsageError = exports.NetworkError = exports.GHESNotSupportedError = exports.CacheNotFoundError = exports.InvalidResponseError = exports.FilesNotFoundError = void 0; +exports.RateLimitError = exports.UsageError = exports.NetworkError = exports.GHESNotSupportedError = exports.CacheNotFoundError = exports.InvalidResponseError = exports.FilesNotFoundError = void 0; class FilesNotFoundError extends Error { constructor(files = []) { let message = 'No files were found to upload'; @@ -2542,6 +2556,13 @@ UsageError.isUsageErrorMessage = (msg) => { return false; return msg.includes('insufficient usage'); }; +class RateLimitError extends Error { + constructor(message) { + super(message); + this.name = 'RateLimitError'; + } +} +exports.RateLimitError = RateLimitError; //# sourceMappingURL=errors.js.map /***/ }), @@ -106076,7 +106097,7 @@ exports.visitAsync = visitAsync; /***/ ((module) => { "use strict"; -module.exports = /*#__PURE__*/JSON.parse('{"name":"@actions/cache","version":"5.0.2","preview":true,"description":"Actions cache lib","keywords":["github","actions","cache"],"homepage":"https://github.com/actions/toolkit/tree/main/packages/cache","license":"MIT","main":"lib/cache.js","types":"lib/cache.d.ts","directories":{"lib":"lib","test":"__tests__"},"files":["lib","!.DS_Store"],"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/actions/toolkit.git","directory":"packages/cache"},"scripts":{"audit-moderate":"npm install && npm audit --json --audit-level=moderate > audit.json","test":"echo \\"Error: run tests from root\\" && exit 1","tsc":"tsc"},"bugs":{"url":"https://github.com/actions/toolkit/issues"},"dependencies":{"@actions/core":"^2.0.0","@actions/exec":"^2.0.0","@actions/glob":"^0.5.0","@protobuf-ts/runtime-rpc":"^2.11.1","@actions/http-client":"^3.0.1","@actions/io":"^2.0.0","@azure/abort-controller":"^1.1.0","@azure/core-rest-pipeline":"^1.22.0","@azure/storage-blob":"^12.29.1","semver":"^6.3.1"},"devDependencies":{"@types/node":"^24.1.0","@types/semver":"^6.0.0","@protobuf-ts/plugin":"^2.9.4","typescript":"^5.2.2"},"overrides":{"uri-js":"npm:uri-js-replace@^1.0.1","node-fetch":"^3.3.2"}}'); +module.exports = /*#__PURE__*/JSON.parse('{"name":"@actions/cache","version":"5.0.3","preview":true,"description":"Actions cache lib","keywords":["github","actions","cache"],"homepage":"https://github.com/actions/toolkit/tree/main/packages/cache","license":"MIT","main":"lib/cache.js","types":"lib/cache.d.ts","directories":{"lib":"lib","test":"__tests__"},"files":["lib","!.DS_Store"],"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/actions/toolkit.git","directory":"packages/cache"},"scripts":{"audit-moderate":"npm install && npm audit --json --audit-level=moderate > audit.json","test":"echo \\"Error: run tests from root\\" && exit 1","tsc":"tsc"},"bugs":{"url":"https://github.com/actions/toolkit/issues"},"dependencies":{"@actions/core":"^2.0.0","@actions/exec":"^2.0.0","@actions/glob":"^0.5.0","@protobuf-ts/runtime-rpc":"^2.11.1","@actions/http-client":"^3.0.1","@actions/io":"^2.0.0","@azure/abort-controller":"^1.1.0","@azure/core-rest-pipeline":"^1.22.0","@azure/storage-blob":"^12.29.1","semver":"^6.3.1"},"devDependencies":{"@types/node":"^24.1.0","@types/semver":"^6.0.0","@protobuf-ts/plugin":"^2.9.4","typescript":"^5.2.2"},"overrides":{"uri-js":"npm:uri-js-replace@^1.0.1","node-fetch":"^3.3.2"}}'); /***/ }) diff --git a/package-lock.json b/package-lock.json index c3278b4..f31d0ca 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,14 +9,14 @@ "version": "8.0.0", "license": "MIT", "dependencies": { - "@actions/cache": "^5.0.2", + "@actions/cache": "^5.0.3", "@actions/core": "^2.0.2", "@actions/exec": "^2.0.0", "@actions/github": "^7.0.0", "@actions/http-client": "^3.0.0", "@actions/tool-cache": "^3.0.0", "@octokit/plugin-retry": "^6.1.0", - "@types/node": "^25.0.6", + "@types/node": "^25.0.9", "@types/semver": "^7.7.1", "@types/tmp": "^0.2.6", "@types/which": "^3.0.4", @@ -41,9 +41,9 @@ } }, "node_modules/@actions/cache": { - "version": "5.0.2", - "resolved": "https://registry.npmjs.org/@actions/cache/-/cache-5.0.2.tgz", - "integrity": "sha512-6w3i9n12eWJyut6TOnh7SIxGmeIepB5wbXMvlPv9+6CjvTD4OYKi1Wjh7TQrjEf8xLb6hxsVCpPsL/1gxnlTtw==", + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/@actions/cache/-/cache-5.0.3.tgz", + "integrity": "sha512-9joY8Oup+nIpksSBlkuf9/mltnhWx3lydk1tA2PVnXaxFLIIrKqrWDN2CZXlJ+PEErcBARKYn4mHiUCTyMh4Vg==", "license": "MIT", "dependencies": { "@actions/core": "^2.0.0", @@ -818,9 +818,9 @@ "dev": true }, "node_modules/@types/node": { - "version": "25.0.6", - "resolved": "https://registry.npmjs.org/@types/node/-/node-25.0.6.tgz", - "integrity": "sha512-NNu0sjyNxpoiW3YuVFfNz7mxSQ+S4X2G28uqg2s+CzoqoQjLPsWSbsFFyztIAqt2vb8kfEAsJNepMGPTxFDx3Q==", + "version": "25.0.9", + "resolved": "https://registry.npmjs.org/@types/node/-/node-25.0.9.tgz", + "integrity": "sha512-/rpCXHlCWeqClNBwUhDcusJxXYDjZTyE8v5oTO7WbL8eij2nKhUeU89/6xgjU7N4/Vh3He0BtyhJdQbDyhiXAw==", "license": "MIT", "dependencies": { "undici-types": "~7.16.0" diff --git a/package.json b/package.json index 5e80694..ed8bc3c 100644 --- a/package.json +++ b/package.json @@ -27,14 +27,14 @@ "node": ">=24.0.0" }, "dependencies": { - "@actions/cache": "^5.0.2", + "@actions/cache": "^5.0.3", "@actions/core": "^2.0.2", "@actions/exec": "^2.0.0", "@actions/github": "^7.0.0", "@actions/http-client": "^3.0.0", "@octokit/plugin-retry": "^6.1.0", "@actions/tool-cache": "^3.0.0", - "@types/node": "^25.0.6", + "@types/node": "^25.0.9", "@types/semver": "^7.7.1", "@types/tmp": "^0.2.6", "@types/which": "^3.0.4",