Skip to content

Commit

Permalink
fix: Update to latest throttling plugin (#53)
Browse files Browse the repository at this point in the history
In attempt to fix unintentional retries on 422 error from GitHub,

1. Update to latest `@octokit/plugin-throttling` version
2. Depend on `@octokit/plugin-retry` plugin as well

Issue: #52
  • Loading branch information
playpauseandstop committed May 25, 2020
1 parent 9a89d1e commit 9439581
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 20 deletions.
38 changes: 34 additions & 4 deletions package-lock.json

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

3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -22,7 +22,8 @@
"dependencies": {
"@actions/core": "^1.2.0",
"@actions/github": "^2.0.0",
"@octokit/plugin-throttling": "^2.7.1",
"@octokit/plugin-retry": "^3.0.2",
"@octokit/plugin-throttling": "^3.2.1",
"glob": "^7.1.6",
"mime": "^2.4.4"
},
Expand Down
35 changes: 20 additions & 15 deletions src/main.ts
Expand Up @@ -10,23 +10,28 @@ async function run() {
if (!config.input_tag_name && !isTag(config.github_ref)) {
throw new Error(`⚠️ GitHub Releases requires a tag`);
}
GitHub.plugin(require("@octokit/plugin-throttling"));
GitHub.plugin([
require("@octokit/plugin-throttling"),
require("@octokit/plugin-retry")
]);
const gh = new GitHub(config.github_token, {
onRateLimit: (retryAfter, options) => {
console.warn(
`Request quota exhausted for request ${options.method} ${options.url}`
);
if (options.request.retryCount === 0) {
// only retries once
console.log(`Retrying after ${retryAfter} seconds!`);
return true;
throttle: {
onRateLimit: (retryAfter, options) => {
console.warn(
`Request quota exhausted for request ${options.method} ${options.url}`
);
if (options.request.retryCount === 0) {
// only retries once
console.log(`Retrying after ${retryAfter} seconds!`);
return true;
}
},
onAbuseLimit: (retryAfter, options) => {
// does not retry, only logs a warning
console.warn(
`Abuse detected for request ${options.method} ${options.url}`
);
}
},
onAbuseLimit: (retryAfter, options) => {
// does not retry, only logs a warning
console.warn(
`Abuse detected for request ${options.method} ${options.url}`
);
}
});
let rel = await release(config, new GitHubReleaser(gh));
Expand Down

0 comments on commit 9439581

Please sign in to comment.