Skip to content

Commit 9e8b8a1

Browse files
authored
Merge pull request #53 from advanced-security/dependabot/npm_and_yarn/octokit/plugin-retry-4.1.3
Bump @octokit/plugin-retry from 3.0.9 to 4.1.3
2 parents d9df55a + d632510 commit 9e8b8a1

File tree

4 files changed

+70
-30
lines changed

4 files changed

+70
-30
lines changed

dist/index.js

+25-19
Original file line numberDiff line numberDiff line change
@@ -4318,58 +4318,64 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
43184318
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
43194319

43204320
var Bottleneck = _interopDefault(__nccwpck_require__(1174));
4321+
var requestError = __nccwpck_require__(537);
43214322

43224323
// @ts-ignore
4323-
async function errorRequest(octokit, state, error, options) {
4324+
async function errorRequest(state, octokit, error, options) {
43244325
if (!error.request || !error.request.request) {
43254326
// address https://github.com/octokit/plugin-retry.js/issues/8
43264327
throw error;
4327-
} // retry all >= 400 && not doNotRetry
4328-
4329-
4328+
}
4329+
// retry all >= 400 && not doNotRetry
43304330
if (error.status >= 400 && !state.doNotRetry.includes(error.status)) {
43314331
const retries = options.request.retries != null ? options.request.retries : state.retries;
43324332
const retryAfter = Math.pow((options.request.retryCount || 0) + 1, 2);
43334333
throw octokit.retry.retryRequest(error, retries, retryAfter);
4334-
} // Maybe eventually there will be more cases here
4335-
4336-
4334+
}
4335+
// Maybe eventually there will be more cases here
43374336
throw error;
43384337
}
43394338

4340-
// @ts-ignore
4341-
4342-
async function wrapRequest(state, request, options) {
4343-
const limiter = new Bottleneck(); // @ts-ignore
4344-
4339+
// @ts-nocheck
4340+
async function wrapRequest(state, octokit, request, options) {
4341+
const limiter = new Bottleneck();
43454342
limiter.on("failed", function (error, info) {
43464343
const maxRetries = ~~error.request.request.retries;
43474344
const after = ~~error.request.request.retryAfter;
43484345
options.request.retryCount = info.retryCount + 1;
4349-
43504346
if (maxRetries > info.retryCount) {
43514347
// Returning a number instructs the limiter to retry
43524348
// the request after that number of milliseconds have passed
43534349
return after * state.retryAfterBaseValue;
43544350
}
43554351
});
4356-
return limiter.schedule(request, options);
4352+
return limiter.schedule(requestWithGraphqlErrorHandling.bind(null, state, octokit, request), options);
4353+
}
4354+
async function requestWithGraphqlErrorHandling(state, octokit, request, options) {
4355+
const response = await request(request, options);
4356+
if (response.data && response.data.errors && /Something went wrong while executing your query/.test(response.data.errors[0].message)) {
4357+
// simulate 500 request error for retry handling
4358+
const error = new requestError.RequestError(response.data.errors[0].message, 500, {
4359+
request: options,
4360+
response
4361+
});
4362+
return errorRequest(state, octokit, error, options);
4363+
}
4364+
return response;
43574365
}
43584366

4359-
const VERSION = "3.0.9";
4367+
const VERSION = "4.1.3";
43604368
function retry(octokit, octokitOptions) {
43614369
const state = Object.assign({
43624370
enabled: true,
43634371
retryAfterBaseValue: 1000,
43644372
doNotRetry: [400, 401, 403, 404, 422],
43654373
retries: 3
43664374
}, octokitOptions.retry);
4367-
43684375
if (state.enabled) {
4369-
octokit.hook.error("request", errorRequest.bind(null, octokit, state));
4370-
octokit.hook.wrap("request", wrapRequest.bind(null, state));
4376+
octokit.hook.error("request", errorRequest.bind(null, state, octokit));
4377+
octokit.hook.wrap("request", wrapRequest.bind(null, state, octokit));
43714378
}
4372-
43734379
return {
43744380
retry: {
43754381
retryRequest: (error, retries, retryAfter) => {

dist/index.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

+43-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"dependencies": {
2828
"@actions/core": "^1.10.0",
2929
"@actions/github": "^5.0.3",
30-
"@octokit/plugin-retry": "^3.0.9",
30+
"@octokit/plugin-retry": "^4.1.3",
3131
"console-log-level": "^1.4.1"
3232
},
3333
"devDependencies": {

0 commit comments

Comments
 (0)