Skip to content

Commit

Permalink
Merge pull request #113 from mrrfv/cf-ratelimit-fix
Browse files Browse the repository at this point in the history
Workaround for a Cloudflare rate limiting problem
  • Loading branch information
mrrfv authored Jun 6, 2024
2 parents 25db4f7 + ee282f6 commit a3ade64
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ export const createZeroTrustListsOneByOne = async (items) => {
totalListNumber--;
listNumber++;
console.log(`Created "${listName}" list - ${totalListNumber} left`);
/*
Sleep for 4 seconds to work around an undocumented Cloudflare API rate limit.
This should be removed once the issue is fixed on their side.
*/
await new Promise((r) => setTimeout(r, 4 * 1000));
} catch (err) {
console.error(`Could not create "${listName}" - ${err.toString()}`);
throw err;
Expand Down Expand Up @@ -106,6 +111,11 @@ export const deleteZeroTrustListsOneByOne = async (lists) => {
await deleteZeroTrustList(id);
totalListNumber--;
console.log(`Deleted ${name} list - ${totalListNumber} left`);
/*
Sleep for 4 seconds to work around an undocumented Cloudflare API rate limit.
This should be removed once the issue is fixed on their side.
*/
await new Promise((r) => setTimeout(r, 4 * 1000));
} catch (err) {
console.error(`Could not delete ${name} - ${err.toString()}`);
throw err;
Expand Down

0 comments on commit a3ade64

Please sign in to comment.