Repository: anuraghazra/github-readme-stats
Pull request #3227 (2023-09-14 08:41:20)

refactor: use more clear retryer error message (2)
Related to https://github.com/anuraghazra/github-readme-stats/issues/3226

I think that retryer error message can be improved one more time to contain information about how users can avoid these error. Current error message "Maximum retries exceeded" is useless since do not tell users anything. I hope this change will reduce count of duplicates of https://github.com/anuraghazra/github-readme-stats/issues/1471

vercel[bot]: [vc]: #7GEedDyJ8tA5e5v3Y6sSC7FYQEwog6o4iVQDxhBkBgU=:eyJpc01vbm9yZXBvIjp0cnVlLCJ0eXBlIjoiZ2l0aHViIiwicHJvamVjdHMiOlt7Im5hbWUiOiJnaXRodWItcmVhZG1lLXN0YXRzIiwiaW5zcGVjdG9yVXJsIjoiaHR0cHM6Ly92ZXJjZWwuY29tL2dpdGh1Yi1yZWFkbWUtc3RhdHMtdGVhbS9naXRodWItcmVhZG1lLXN0YXRzL0ZaV3hCNmQ4Z3ROWTJjVjhoQ205VlJHb3ZVdHkiLCJwcmV2aWV3VXJsIjoiZ2l0aHViLXJlYWRtZS1zdGF0cy1naXQtcmVmYWN0by03ZjVkZTMtZ2l0aHViLXJlYWRtZS1zdGF0cy10ZWFtLnZlcmNlbC5hcHAiLCJuZXh0Q29tbWl0U3RhdHVzIjoiREVQTE9ZRUQifV19
**The latest updates on your projects**. Learn more about [Vercel for Git ↗︎](https://vercel.link/github-learn-more)

| Name | Status | Preview | Updated (UTC) |
| :--- | :----- | :------ | :------ |
| **github-readme-stats** | ✅ Ready ([Inspect](https://vercel.com/github-readme-stats-team/github-readme-stats/FZWxB6d8gtNY2cV8hCm9VRGovUty)) | [Visit Preview](https://github-readme-stats-git-refacto-7f5de3-github-readme-stats-team.vercel.app) | Sep 14, 2023 8:41am |


codecov[bot]: ## [Codecov](https://app.codecov.io/gh/anuraghazra/github-readme-stats/pull/3227?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Anurag+Hazra) Report
Patch coverage: **`100.00%`** and no project coverage change.
> Comparison is base [(`81f030f`)](https://app.codecov.io/gh/anuraghazra/github-readme-stats/commit/81f030fd1cc331d95cadd05f0558cdd53f1a57f1?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Anurag+Hazra) 98.38% compared to head [(`133a2bb`)](https://app.codecov.io/gh/anuraghazra/github-readme-stats/pull/3227?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Anurag+Hazra) 98.38%.

<details><summary>Additional details and impacted files</summary>


```diff
@@           Coverage Diff           @@
##           master    #3227   +/-   ##
=======================================
  Coverage   98.38%   98.38%           
=======================================
  Files          27       27           
  Lines        5880     5884    +4     
  Branches      525      525           
=======================================
+ Hits         5785     5789    +4     
  Misses         92       92           
  Partials        3        3           
```


| [Files Changed](https://app.codecov.io/gh/anuraghazra/github-readme-stats/pull/3227?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Anurag+Hazra) | Coverage Δ | |
|---|---|---|
| [src/common/retryer.js](https://app.codecov.io/gh/anuraghazra/github-readme-stats/pull/3227?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Anurag+Hazra#diff-c3JjL2NvbW1vbi9yZXRyeWVyLmpz) | `94.73% <100.00%> (+0.21%)` | :arrow_up: |
| [src/common/utils.js](https://app.codecov.io/gh/anuraghazra/github-readme-stats/pull/3227?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Anurag+Hazra#diff-c3JjL2NvbW1vbi91dGlscy5qcw==) | `98.93% <100.00%> (+<0.01%)` | :arrow_up: |


</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/anuraghazra/github-readme-stats/pull/3227?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Anurag+Hazra).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Anurag+Hazra).


Patch:
diff --git a/src/common/retryer.js b/src/common/retryer.js
index 2a441f1..74f9a0f 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 0bf2d05..871c493 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",


Test patch:
diff --git a/tests/retryer.test.js b/tests/retryer.test.js
index 2229bbb..257a70d 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");
     }
   });
 });