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
40
package-lock.json
generated
40
package-lock.json
generated
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "action-gh-release",
|
||||
"version": "0.1.4",
|
||||
"version": "0.1.5",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
@ -434,12 +434,42 @@
|
||||
"universal-user-agent": "^4.0.0"
|
||||
}
|
||||
},
|
||||
"@octokit/plugin-throttling": {
|
||||
"version": "2.7.1",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/plugin-throttling/-/plugin-throttling-2.7.1.tgz",
|
||||
"integrity": "sha512-08CKNFCpSpmOEAQBn6/MR8zbJgjP4+bplNUJbKlqJSNBHTO1NdsDHzBD4VeFYopOo7rBEySng4WifxNVaQ5bVw==",
|
||||
"@octokit/plugin-retry": {
|
||||
"version": "3.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/plugin-retry/-/plugin-retry-3.0.2.tgz",
|
||||
"integrity": "sha512-k7xl2WLfLP7WirRXRHtCq5xGAIXBZHV9X3HVUJhPwe8/N8vVzxPcnnnBL5NpEep/+GQqFRdYxrkgz68VY3z2wA==",
|
||||
"requires": {
|
||||
"@octokit/types": "^4.0.1",
|
||||
"bottleneck": "^2.15.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@octokit/types": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/types/-/types-4.0.1.tgz",
|
||||
"integrity": "sha512-Ho6h7w2h9y8RRE8r656hIj1oiSbwbIHJGF5r9G5FOwS2VdDPq8QLGvsG4x6pKHpvyGK7j+43sAc2cJKMiFoIJw==",
|
||||
"requires": {
|
||||
"@types/node": ">= 8"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"@octokit/plugin-throttling": {
|
||||
"version": "3.2.1",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/plugin-throttling/-/plugin-throttling-3.2.1.tgz",
|
||||
"integrity": "sha512-CGr3IagYZLLV3pFgpTQUthQSS5K3BkHLlG8yXK+Op3UKBkYrTf+Y9pCebrDxt60d+VTQ1oxXCx+LVLYY3IhBZQ==",
|
||||
"requires": {
|
||||
"@octokit/types": "^4.0.1",
|
||||
"bottleneck": "^2.15.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@octokit/types": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/types/-/types-4.0.1.tgz",
|
||||
"integrity": "sha512-Ho6h7w2h9y8RRE8r656hIj1oiSbwbIHJGF5r9G5FOwS2VdDPq8QLGvsG4x6pKHpvyGK7j+43sAc2cJKMiFoIJw==",
|
||||
"requires": {
|
||||
"@types/node": ">= 8"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"@octokit/request": {
|
||||
|
@ -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"
|
||||
},
|
||||
|
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…
x
Reference in New Issue
Block a user