Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Instead of retrying after 1 second, use a random delay up to 11 seconds. #43

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
});
}
Expand Down