From 110f06578da9fa4f5389269e9c86e56558a2d7dc Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Sat, 7 May 2011 12:30:53 -0700 Subject: [PATCH] Agent socket errors bubble up to req only if req exists Fixes #836. --- lib/http.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/http.js b/lib/http.js index 1e7512d5425..72944148938 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();