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

refactor: use more clear retryer error message (2) #3227

Merged
merged 1 commit into from
Sep 14, 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
5 changes: 4 additions & 1 deletion src/common/retryer.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ const retryer = async (fetcher, variables, retries = 0) => {
throw new CustomError("No GitHub API tokens found", CustomError.NO_TOKENS);
}
if (retries > RETRIES) {
throw new CustomError("Maximum retries exceeded", CustomError.MAX_RETRY);
throw new CustomError(
"Downtime due to GitHub API rate limiting",
CustomError.MAX_RETRY,
);
}
try {
// try to fetch with the first token since RETRIES is 0 index i'm adding +1
Expand Down
3 changes: 2 additions & 1 deletion src/common/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,8 @@ const CONSTANTS = {
};

const SECONDARY_ERROR_MESSAGES = {
MAX_RETRY: "Downtime due to GitHub API rate limiting",
MAX_RETRY:
"You can deploy own instance or wait until public will be no longer limited",
NO_TOKENS:
"Please add an env variable called PAT_1 with your GitHub API token in vercel",
USER_NOT_FOUND: "Make sure the provided username is not an organization",
Expand Down
4 changes: 2 additions & 2 deletions tests/retryer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ describe("Test Retryer", () => {
expect(res).toStrictEqual({ data: "ok" });
});

it("retryer should throw error if maximum retries reached", async () => {
it("retryer should throw specific error if maximum retries reached", async () => {
try {
await retryer(fetcherFail, {});
} catch (err) {
expect(fetcherFail).toBeCalledTimes(8);
expect(err.message).toBe("Maximum retries exceeded");
expect(err.message).toBe("Downtime due to GitHub API rate limiting");
}
});
});
Loading