Skip to content

Commit f07cd13

Browse files
authored
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
1 parent 42a4b6f commit f07cd13

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/common/retryer.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import { CustomError, logger } from "./utils.js";
22

3+
// Script variables.
4+
const PATs = Object.keys(process.env).filter((key) =>
5+
/PAT_\d*$/.exec(key),
6+
).length;
7+
const RETRIES = PATs ? PATs : 7;
8+
39
/**
410
* Try to execute the fetcher function until it succeeds or the max number of retries is reached.
511
*
@@ -10,7 +16,7 @@ import { CustomError, logger } from "./utils.js";
1016
* @returns Promise<retryer>
1117
*/
1218
const retryer = async (fetcher, variables, retries = 0) => {
13-
if (retries > 7) {
19+
if (retries > RETRIES) {
1420
throw new CustomError("Maximum retries exceeded", CustomError.MAX_RETRY);
1521
}
1622
try {

0 commit comments

Comments
 (0)