Skip to content

Commit

Permalink
Merge pull request #191 from pelias/fix-no-test-handling
Browse files Browse the repository at this point in the history
fix: Handle both no tests existing, and no remaining tests to call
  • Loading branch information
orangejulius authored May 5, 2020
2 parents 3c3d447 + 0f1de9e commit b2087bc
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/request_urls.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,22 @@ function request_urls(config, urls, callback) {
var delay = test_interval.getBackoff();

var getOneUrl = function (){
if( urls.length === 0 ){
// check if all responses have been recieved and call the next step in
// processing via the `callback` function
if( Object.keys(responses).length === total_length ){
clearInterval(intervalId);
return callback([]);
return callback( responses );
}

var url = urls.pop();

// if there are no more URLs to send requests for, we might
// be waiting for some to finish, so just return and the next call to
// this function from the ExponentialBackoff manager will try again
if (!url) {
return;
}

const agent = (url.startsWith('https:')) ? httpsAgent : httpAgent;

var requestOpts = {
Expand Down

0 comments on commit b2087bc

Please sign in to comment.