@@ -4318,58 +4318,64 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
4318
4318
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
4319
4319
4320
4320
var Bottleneck = _interopDefault(__nccwpck_require__(1174));
4321
+ var requestError = __nccwpck_require__(537);
4321
4322
4322
4323
// @ts-ignore
4323
- async function errorRequest(octokit, state , error, options) {
4324
+ async function errorRequest(state, octokit , error, options) {
4324
4325
if (!error.request || !error.request.request) {
4325
4326
// address https://github.com/octokit/plugin-retry.js/issues/8
4326
4327
throw error;
4327
- } // retry all >= 400 && not doNotRetry
4328
-
4329
-
4328
+ }
4329
+ // retry all >= 400 && not doNotRetry
4330
4330
if (error.status >= 400 && !state.doNotRetry.includes(error.status)) {
4331
4331
const retries = options.request.retries != null ? options.request.retries : state.retries;
4332
4332
const retryAfter = Math.pow((options.request.retryCount || 0) + 1, 2);
4333
4333
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
4337
4336
throw error;
4338
4337
}
4339
4338
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();
4345
4342
limiter.on("failed", function (error, info) {
4346
4343
const maxRetries = ~~error.request.request.retries;
4347
4344
const after = ~~error.request.request.retryAfter;
4348
4345
options.request.retryCount = info.retryCount + 1;
4349
-
4350
4346
if (maxRetries > info.retryCount) {
4351
4347
// Returning a number instructs the limiter to retry
4352
4348
// the request after that number of milliseconds have passed
4353
4349
return after * state.retryAfterBaseValue;
4354
4350
}
4355
4351
});
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;
4357
4365
}
4358
4366
4359
- const VERSION = "3.0.9 ";
4367
+ const VERSION = "4.1.3 ";
4360
4368
function retry(octokit, octokitOptions) {
4361
4369
const state = Object.assign({
4362
4370
enabled: true,
4363
4371
retryAfterBaseValue: 1000,
4364
4372
doNotRetry: [400, 401, 403, 404, 422],
4365
4373
retries: 3
4366
4374
}, octokitOptions.retry);
4367
-
4368
4375
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 ));
4371
4378
}
4372
-
4373
4379
return {
4374
4380
retry: {
4375
4381
retryRequest: (error, retries, retryAfter) => {
0 commit comments