mirror of
https://forgejo.stefka.eu/jiriks74/create-pull-request.git
synced 2025-01-18 16:01:06 +01:00
feat: retry 403
This commit is contained in:
parent
ce53a56b63
commit
83dbed188f
4 changed files with 37 additions and 4 deletions
12
dist/index.js
vendored
12
dist/index.js
vendored
|
@ -984,7 +984,9 @@ const octokit_client_1 = __nccwpck_require__(5040);
|
|||
const ERROR_PR_REVIEW_FROM_AUTHOR = 'Review cannot be requested from pull request author';
|
||||
class GitHubHelper {
|
||||
constructor(token) {
|
||||
const options = {};
|
||||
const options = {
|
||||
retry: octokit_client_1.retryOptions
|
||||
};
|
||||
if (token) {
|
||||
options.auth = `${token}`;
|
||||
}
|
||||
|
@ -1176,7 +1178,7 @@ run();
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.Octokit = void 0;
|
||||
exports.retryOptions = exports.Octokit = void 0;
|
||||
const core_1 = __nccwpck_require__(6762);
|
||||
const plugin_paginate_rest_1 = __nccwpck_require__(4193);
|
||||
const plugin_rest_endpoint_methods_1 = __nccwpck_require__(3044);
|
||||
|
@ -1193,6 +1195,12 @@ function autoProxyAgent(octokit) {
|
|||
options.request.agent = agent;
|
||||
});
|
||||
}
|
||||
exports.retryOptions = {
|
||||
// Allow retry for 403 (rate-limiting / abuse detection)
|
||||
doNotRetry: [400, 401, 404, 422],
|
||||
retryAfterBaseValue: 2000,
|
||||
retries: 3
|
||||
};
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
|
16
package-lock.json
generated
16
package-lock.json
generated
|
@ -14,6 +14,8 @@
|
|||
"@octokit/core": "3.5.1",
|
||||
"@octokit/plugin-paginate-rest": "2.14.0",
|
||||
"@octokit/plugin-rest-endpoint-methods": "5.5.0",
|
||||
"@octokit/plugin-retry": "3.0.7",
|
||||
"bottleneck": "2.19.5",
|
||||
"https-proxy-agent": "5.0.0",
|
||||
"uuid": "8.3.2"
|
||||
},
|
||||
|
@ -1421,6 +1423,15 @@
|
|||
"@octokit/core": ">=3"
|
||||
}
|
||||
},
|
||||
"node_modules/@octokit/plugin-retry": {
|
||||
"version": "3.0.7",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/plugin-retry/-/plugin-retry-3.0.7.tgz",
|
||||
"integrity": "sha512-n08BPfVeKj5wnyH7IaOWnuKbx+e9rSJkhDHMJWXLPv61625uWjsN8G7sAW3zWm9n9vnS4friE7LL/XLcyGeG8Q==",
|
||||
"dependencies": {
|
||||
"@octokit/types": "^6.0.3",
|
||||
"bottleneck": "^2.15.3"
|
||||
}
|
||||
},
|
||||
"node_modules/@octokit/request": {
|
||||
"version": "5.6.0",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/request/-/request-5.6.0.tgz",
|
||||
|
@ -2179,6 +2190,11 @@
|
|||
"resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-2.2.2.tgz",
|
||||
"integrity": "sha512-3pZEU3NT5BFUo/AD5ERPWOgQOCZITni6iavr5AUw5AUwQjMlI0kzu5btnyD39AF0gUEsDPwJT+oY1ORBJijPjQ=="
|
||||
},
|
||||
"node_modules/bottleneck": {
|
||||
"version": "2.19.5",
|
||||
"resolved": "https://registry.npmjs.org/bottleneck/-/bottleneck-2.19.5.tgz",
|
||||
"integrity": "sha512-VHiNCbI1lKdl44tGrhNfU3lup0Tj/ZBMJB5/2ZbNXRCPuRCO7ed2mgcK4r17y+KB2EfuYuRaVlwNbAeaWGSpbw=="
|
||||
},
|
||||
"node_modules/brace-expansion": {
|
||||
"version": "1.1.11",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import * as core from '@actions/core'
|
||||
import {Inputs} from './create-pull-request'
|
||||
import {Octokit, OctokitOptions} from './octokit-client'
|
||||
import {Octokit, OctokitOptions, retryOptions} from './octokit-client'
|
||||
|
||||
const ERROR_PR_REVIEW_FROM_AUTHOR =
|
||||
'Review cannot be requested from pull request author'
|
||||
|
@ -20,7 +20,9 @@ export class GitHubHelper {
|
|||
private octokit: InstanceType<typeof Octokit>
|
||||
|
||||
constructor(token: string) {
|
||||
const options: OctokitOptions = {}
|
||||
const options: OctokitOptions = {
|
||||
retry: retryOptions
|
||||
}
|
||||
if (token) {
|
||||
options.auth = `${token}`
|
||||
}
|
||||
|
|
|
@ -23,3 +23,10 @@ function autoProxyAgent(octokit: Core) {
|
|||
options.request.agent = agent
|
||||
})
|
||||
}
|
||||
|
||||
export const retryOptions = {
|
||||
// Allow retry for 403 (rate-limiting / abuse detection)
|
||||
doNotRetry: [400, 401, 404, 422],
|
||||
retryAfterBaseValue: 2000,
|
||||
retries: 3
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue