http-request
http-request copied to clipboard
http.get running twice on timeout
Using async.auto I am running an http.get() with timeout. After the timeout error, http.get is ran again causing a Callback is already called error. I am getting this error because http.get is ran twice, one time after the timeout.
An code example proving the issue is always welcome.
Sorry for the delay. This codes replicates the error, just change the URL to an unresponsive to generate the timeout, or set the timeout really low.
var async = require('async'),
http = require('http-get'),
URL = "unresponsive-url.com";
console.log("Starting");
async.auto({
one: function(callback) {
console.log("Running http-get");
http.get(
{
timeout: 5000,
url: URL
},
function(err, res) {
console.log("Running http-get callback");
if(err){
console.log("error");
}
else {
console.log("OK");
}
callback(callback);
}
);
},
two: ['one',
function (callback) {
console.log("Running two");
callback(callback);
}
]
}, function(err, results) {
console.log("Running callback.");
});