Agent socket errors bubble up to req only if req exists

Fixes #836.
v0.7.4-release
Ryan Dahl 2011-05-07 12:30:53 -07:00
parent c2b5ea218c
commit 110f06578d
1 changed files with 4 additions and 5 deletions

View File

@ -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();