Skip to content

Commit

Permalink
Updates for GitHub secondary rate limit renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
bflad committed Dec 10, 2021
1 parent 134c783 commit d402928
Show file tree
Hide file tree
Showing 5 changed files with 4,957 additions and 15 deletions.
6 changes: 3 additions & 3 deletions action.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,12 @@ describe('action', () => {
});
});

test('retries abuse limit errors', (done) => {
test('retries secondary rate limit errors', (done) => {
const scope = nock('https://api.github.com')
.get('/repos/hashicorp/hc-releases/releases/tags/v0.11.4')
.reply(403, {
message: "You have triggered an abuse detection mechanism and have been temporarily blocked from content creation. Please retry your request again later.",
documentation_url: "https://docs.github.com/rest/overview/resources-in-the-rest-api#abuse-rate-limits"
message: "You have exceeded a secondary rate limit and have been temporarily blocked from content creation. Please retry your request again later.",
documentation_url: "https://docs.github.com/rest/overview/resources-in-the-rest-api#secondary-rate-limits"
})
.get('/repos/hashicorp/hc-releases/releases/tags/v0.11.4')
.reply(200, mockRelease)
Expand Down
12 changes: 6 additions & 6 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions octokit.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ const { GitHub, getOctokitOptions } = require('@actions/github/lib/utils')
const { retry } = require('@octokit/plugin-retry')
const { throttling } = require('@octokit/plugin-throttling')

const abuseLimitRetries = 5
const rateLimitRetries = 5
const secondaryRateLimitRetries = 5

module.exports = function client(token) {
const Octokit = GitHub.plugin(throttling, retry);
Expand All @@ -19,14 +19,14 @@ module.exports = function client(token) {

options.throttle = {
onAbuseLimit(retryAfter, options) {
core.info(`Abuse limit triggered for request ${options.method} ${options.url} (attempt ${options.request.retryCount}/${abuseLimitRetries})`)
core.info(`Secondary rate limit triggered for request ${options.method} ${options.url} (attempt ${options.request.retryCount}/${secondaryRateLimitRetries})`)

if (options.request.retryCount < abuseLimitRetries) {
if (options.request.retryCount < secondaryRateLimitRetries) {
core.info(`Retrying after ${retryAfter} seconds`)
return true
}

core.warning(`Exhausted abuse limit retry count (${abuseLimitRetries}) for ${options.method} ${options.url}`)
core.warning(`Exhausted secondary rate limit retry count (${secondaryRateLimitRetries}) for ${options.method} ${options.url}`)
},
onRateLimit(retryAfter, options) {
core.info(`Rate limit triggered for request ${options.method} ${options.url} (attempt ${options.request.retryCount}/${rateLimitRetries})`)
Expand Down
Loading

0 comments on commit d402928

Please sign in to comment.