From 38d0ea1d992eaf4810c61f91ac68b7a06f6117b2 Mon Sep 17 00:00:00 2001 From: Steve Mokris Date: Fri, 19 Jun 2020 21:25:02 -0400 Subject: [PATCH] Instead of retrying after 1 second, use a random delay up to 11 seconds. Closes #25. --- index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 0258eef..9292e14 100755 --- a/index.js +++ b/index.js @@ -173,8 +173,9 @@ class Scanner { } // try again - logger.warn(sprintf("retrying in 1 second (attempt %s/%s)", that.attempts, that.allowed)); - return delay(1000).then(function() { + var interval = 1 + Math.ceil(Math.random() * Math.floor(10)); + logger.warn(sprintf("retrying in %d seconds (attempt %s/%s)", interval, that.attempts, that.allowed)); + return delay(interval * 1000).then(function() { return that.promiseScan(site, options, "get"); }); }