Created
March 10, 2011 23:29
-
-
Save ithinkihaveacat/865174 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| From 4d80c2dc876e7bffde2b23825587518c4bd7b678 Mon Sep 17 00:00:00 2001 | |
| From: Michael Stillwell <[email protected]> | |
| Date: Thu, 10 Mar 2011 23:23:12 +0000 | |
| Subject: [PATCH] Only emit error on request if request can be found. | |
| If the socket receives a "ECONNRESET, Connection reset by peer" error, the http error handler tries to find the associated request from the request queue. However at this point in time, all requests may have been satisfied (e.g. by other sockets) and the queue empty. | |
| --- | |
| lib/http.js | 15 +++------------ | |
| 1 files changed, 3 insertions(+), 12 deletions(-) | |
| diff --git a/lib/http.js b/lib/http.js | |
| index ca813c0..ee967f5 100644 | |
| --- a/lib/http.js | |
| +++ b/lib/http.js | |
| @@ -1159,21 +1159,12 @@ Agent.prototype._establishNewConnection = function() { | |
| socket.on('error', function(err) { | |
| debug('AGENT SOCKET ERROR: ' + err.message); | |
| - var req; | |
| if (socket._httpMessage) { | |
| - req = socket._httpMessage; | |
| - } else if (self.queue.length) { | |
| - req = self.queue.shift(); | |
| - assert(req._queue === self.queue); | |
| - req._queue = null; | |
| - } else { | |
| - // No requests on queue? Where is the request | |
| - assert(0); | |
| + var req = socket._httpMessage; | |
| + req.emit('error', err); | |
| + req._hadError = true; // hacky | |
| } | |
| - req.emit('error', err); | |
| - req._hadError = true; // hacky | |
| - | |
| // clean up so that agent can handle new requests | |
| parser.finish(); | |
| socket.destroy(); | |
| -- | |
| 1.7.4.1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment