mirror of
https://github.com/tiennm99/github-readme-stats.git
synced 2026-08-18 06:26:05 +00:00
fix: fix retry max-out bug (#2121)
* fix: fix retry max-out bug This commit makes sure that the retry function tests all PATs. * style: format code * test: fix retry tests * style: format code
This commit is contained in:
@@ -1,5 +1,11 @@
|
||||
import { CustomError, logger } from "./utils.js";
|
||||
|
||||
// Script variables.
|
||||
const PATs = Object.keys(process.env).filter((key) =>
|
||||
/PAT_\d*$/.exec(key),
|
||||
).length;
|
||||
const RETRIES = PATs ? PATs : 7;
|
||||
|
||||
/**
|
||||
* Try to execute the fetcher function until it succeeds or the max number of retries is reached.
|
||||
*
|
||||
@@ -10,7 +16,7 @@ import { CustomError, logger } from "./utils.js";
|
||||
* @returns Promise<retryer>
|
||||
*/
|
||||
const retryer = async (fetcher, variables, retries = 0) => {
|
||||
if (retries > 7) {
|
||||
if (retries > RETRIES) {
|
||||
throw new CustomError("Maximum retries exceeded", CustomError.MAX_RETRY);
|
||||
}
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user