Files
codeql-action/node_modules/@octokit/plugin-retry/dist-src/index.js
2023-07-13 09:09:17 +00:00

36 lines
889 B
JavaScript

import { Octokit } from "@octokit/core";
import { errorRequest } from "./error-request";
import { wrapRequest } from "./wrap-request";
const VERSION = "0.0.0-development";
function retry(octokit, octokitOptions) {
const state = Object.assign(
{
enabled: true,
retryAfterBaseValue: 1e3,
doNotRetry: [400, 401, 403, 404, 422, 451],
retries: 3
},
octokitOptions.retry
);
if (state.enabled) {
octokit.hook.error("request", errorRequest.bind(null, state, octokit));
octokit.hook.wrap("request", wrapRequest.bind(null, state, octokit));
}
return {
retry: {
retryRequest: (error, retries, retryAfter) => {
error.request.request = Object.assign({}, error.request.request, {
retries,
retryAfter
});
return error;
}
}
};
}
retry.VERSION = VERSION;
export {
VERSION,
retry
};