Skip to content

Commit

Permalink
fix: fix retry max-out bug (#2121)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
rickstaa authored Nov 21, 2022
1 parent 42a4b6f commit f07cd13
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/common/retryer.js
Original file line number Diff line number Diff line change
@@ -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.
*
Expand All @@ -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 {
Expand Down

1 comment on commit f07cd13

@vercel
Copy link

@vercel vercel bot commented on f07cd13 Nov 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.