diff --git a/lib/http.js b/lib/http.js index 1e7512d542..7294414893 100644 --- a/lib/http.js +++ b/lib/http.js @@ -1194,13 +1194,12 @@ Agent.prototype._establishNewConnection = function() { req = self.queue.shift(); assert(req._queue === self.queue); req._queue = null; - } else { - // No requests on queue? Where is the request - assert(0); } - req.emit('error', err); - req._hadError = true; // hacky + if (req) { + req.emit('error', err); + req._hadError = true; // hacky + } // clean up so that agent can handle new requests parser.finish();