Bump @octokit/plugin-retry from 4.0.4 to 5.0.2 (#1726)
* Bump @octokit/plugin-retry from 4.0.4 to 5.0.2 Bumps [@octokit/plugin-retry](https://github.com/octokit/plugin-retry.js) from 4.0.4 to 5.0.2. - [Release notes](https://github.com/octokit/plugin-retry.js/releases) - [Commits](https://github.com/octokit/plugin-retry.js/compare/v4.0.4...v5.0.2) --- updated-dependencies: - dependency-name: "@octokit/plugin-retry" dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * Update checked-in dependencies --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Angela P Wen <angelapwen@github.com>
This commit is contained in:
parent
5fa98fa5b2
commit
b8f204c619
16 changed files with 279 additions and 184 deletions
48
node_modules/@octokit/plugin-retry/dist-src/wrap-request.js
generated
vendored
48
node_modules/@octokit/plugin-retry/dist-src/wrap-request.js
generated
vendored
|
|
@ -1,18 +1,34 @@
|
|||
// @ts-ignore
|
||||
import Bottleneck from "bottleneck/light";
|
||||
// @ts-ignore
|
||||
export async function wrapRequest(state, request, options) {
|
||||
const limiter = new Bottleneck();
|
||||
// @ts-ignore
|
||||
limiter.on("failed", function (error, info) {
|
||||
const maxRetries = ~~error.request.request.retries;
|
||||
const after = ~~error.request.request.retryAfter;
|
||||
options.request.retryCount = info.retryCount + 1;
|
||||
if (maxRetries > info.retryCount) {
|
||||
// Returning a number instructs the limiter to retry
|
||||
// the request after that number of milliseconds have passed
|
||||
return after * state.retryAfterBaseValue;
|
||||
}
|
||||
});
|
||||
return limiter.schedule(request, options);
|
||||
import { RequestError } from "@octokit/request-error";
|
||||
import { errorRequest } from "./error-request";
|
||||
async function wrapRequest(state, octokit, request, options) {
|
||||
const limiter = new Bottleneck();
|
||||
limiter.on("failed", function(error, info) {
|
||||
const maxRetries = ~~error.request.request.retries;
|
||||
const after = ~~error.request.request.retryAfter;
|
||||
options.request.retryCount = info.retryCount + 1;
|
||||
if (maxRetries > info.retryCount) {
|
||||
return after * state.retryAfterBaseValue;
|
||||
}
|
||||
});
|
||||
return limiter.schedule(
|
||||
requestWithGraphqlErrorHandling.bind(null, state, octokit, request),
|
||||
options
|
||||
);
|
||||
}
|
||||
async function requestWithGraphqlErrorHandling(state, octokit, request, options) {
|
||||
const response = await request(request, options);
|
||||
if (response.data && response.data.errors && /Something went wrong while executing your query/.test(
|
||||
response.data.errors[0].message
|
||||
)) {
|
||||
const error = new RequestError(response.data.errors[0].message, 500, {
|
||||
request: options,
|
||||
response
|
||||
});
|
||||
return errorRequest(state, octokit, error, options);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
export {
|
||||
wrapRequest
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue