From ac6cf318796f36afd6c42eaaa2baf2783c13e8dc Mon Sep 17 00:00:00 2001 From: Jose Varela Date: Mon, 10 Jul 2023 06:28:46 +0100 Subject: [PATCH] Increase delay between retries using exponential backoff --- gatsby-node.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/gatsby-node.js b/gatsby-node.js index 155630c..813728d 100644 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -240,7 +240,7 @@ class Plugin { } if (count > 0) { - await sleep(randInt(1000, 8000)); + await sleep(Math.pow(2, count) * 1000); } } @@ -346,10 +346,6 @@ function warning(message) { Log.warning(message); } -function randInt(min, max) { - return Math.floor(Math.random() * (max - min + 1) + min); -} - function sleep(ms) { return new Promise((res) => setTimeout(res, ms)); }