forked from mirrors/action-gh-release
fix: Update to latest throttling plugin (#53)
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
This commit is contained in:
parent
9a89d1e63f
commit
9439581056
3 changed files with 57 additions and 21 deletions
35
src/main.ts
35
src/main.ts
|
@ -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));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue