From 133a2bb4a6cb2a759bf31a9a935b1fc72c5d7f56 Mon Sep 17 00:00:00 2001 From: Alexandr Date: Thu, 14 Sep 2023 11:36:56 +0300 Subject: [PATCH] refactor: use more clear retryer error message (2) --- src/common/retryer.js | 5 ++++- src/common/utils.js | 3 ++- tests/retryer.test.js | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/common/retryer.js b/src/common/retryer.js index 2a441f15a0dd0..74f9a0fd3de2c 100644 --- a/src/common/retryer.js +++ b/src/common/retryer.js @@ -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 diff --git a/src/common/utils.js b/src/common/utils.js index 0bf2d05fa06f6..871c49377df9d 100644 --- a/src/common/utils.js +++ b/src/common/utils.js @@ -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", diff --git a/tests/retryer.test.js b/tests/retryer.test.js index 2229bbb2f565e..257a70d1ba40e 100644 --- a/tests/retryer.test.js +++ b/tests/retryer.test.js @@ -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"); } }); });