mirror of
https://github.com/anuraghazra/github-readme-stats.git
synced 2025-02-11 14:31:55 +08: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:
parent
42a4b6f60a
commit
f07cd133d3
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user