Permalink
Cannot retrieve contributors at this time
34 lines (34 sloc)
1.16 KB
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
codeql-action/node_modules/@octokit/plugin-retry/dist-src/wrap-request.js
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Bottleneck from "bottleneck/light"; | |
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 | |
}; |