Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): update dependency prettier to v3 #449

Merged
merged 3 commits into from
Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const octokit = new MyOctokit({ auth: "secret123" });
octokit.request("/").catch((error) => {
if (error.request.request.retryCount) {
console.log(
`request failed after ${error.request.request.retryCount} retries`
`request failed after ${error.request.request.retryCount} retries`,
);
}

Expand Down Expand Up @@ -84,7 +84,7 @@ octokit
.catch((error) => {
if (error.request.request.retryCount) {
console.log(
`request failed after ${error.request.request.retryCount} retries`
`request failed after ${error.request.request.retryCount} retries`,
);
}

Expand Down
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"fetch-mock": "^9.0.0",
"glob": "^10.2.6",
"jest": "^29.0.0",
"prettier": "2.8.8",
"prettier": "3.0.0",
"semantic-release-plugin-update-version-in-files": "^1.0.0",
"ts-jest": "^29.0.0",
"typescript": "^5.0.0"
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export function retry(octokit: Octokit, octokitOptions: any) {
doNotRetry: [400, 401, 403, 404, 422, 451],
retries: 3,
},
octokitOptions.retry
octokitOptions.retry,
);

if (state.enabled) {
Expand All @@ -27,7 +27,7 @@ export function retry(octokit: Octokit, octokitOptions: any) {
retryRequest: (
error: RequestError,
retries: number,
retryAfter: number
retryAfter: number,
) => {
error.request.request = Object.assign({}, error.request.request, {
retries: retries,
Expand Down
6 changes: 3 additions & 3 deletions src/wrap-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,23 @@ export async function wrapRequest(state, octokit, request, options) {

return limiter.schedule(
requestWithGraphqlErrorHandling.bind(null, state, octokit, request),
options
options,
);
}

async function requestWithGraphqlErrorHandling(
state,
octokit,
request,
options
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
response.data.errors[0].message,
)
) {
// simulate 500 request error for retry handling
Expand Down
18 changes: 9 additions & 9 deletions test/retry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe("Automatic Retries", function () {
]);

expect(
octokit.__requestTimings[1] - octokit.__requestTimings[0]
octokit.__requestTimings[1] - octokit.__requestTimings[0],
).toBeLessThan(20);
});

Expand Down Expand Up @@ -77,10 +77,10 @@ describe("Automatic Retries", function () {
"START GET /route",
]);
expect(
octokit.__requestTimings[1] - octokit.__requestTimings[0]
octokit.__requestTimings[1] - octokit.__requestTimings[0],
).toBeLessThan(20);
expect(
octokit.__requestTimings[2] - octokit.__requestTimings[1]
octokit.__requestTimings[2] - octokit.__requestTimings[1],
).toBeLessThan(20);
});

Expand Down Expand Up @@ -134,7 +134,7 @@ describe("Automatic Retries", function () {

// null (0) retryAfter
expect(
octokit.__requestTimings[3] - octokit.__requestTimings[2]
octokit.__requestTimings[3] - octokit.__requestTimings[2],
).toBeLessThan(20);
});

Expand Down Expand Up @@ -228,7 +228,7 @@ describe("Automatic Retries", function () {

expect(caught).toEqual(testStatuses.length);
expect(octokit.__requestLog).toStrictEqual(
testStatuses.map(() => "START GET /route")
testStatuses.map(() => "START GET /route"),
);
});

Expand Down Expand Up @@ -319,7 +319,7 @@ describe("Automatic Retries", function () {
]);

expect(
octokit.__requestTimings[1] - octokit.__requestTimings[0]
octokit.__requestTimings[1] - octokit.__requestTimings[0],
).toBeLessThan(20);
});

Expand Down Expand Up @@ -385,7 +385,7 @@ describe("Automatic Retries", function () {
} catch (error: any) {
expect(error.name).toEqual("GraphqlResponseError");
expect(error.message).toContain(
"Something that cannot be fixed with a request retry"
"Something that cannot be fixed with a request retry",
);
}

Expand All @@ -395,7 +395,7 @@ describe("Automatic Retries", function () {
]);

expect(
octokit.__requestTimings[1] - octokit.__requestTimings[0]
octokit.__requestTimings[1] - octokit.__requestTimings[0],
).toBeLessThan(20);
});
});
Expand All @@ -421,7 +421,7 @@ describe("errorRequest", function () {
const error = new RequestError(
"Internal server error",
500,
errorOptions
errorOptions,
) as any;
delete error.request;

Expand Down