From bfe9cdb7f2f9b90c95a221dcdce29263f0da5c75 Mon Sep 17 00:00:00 2001 From: isaacs Date: Tue, 1 May 2012 14:26:18 -0700 Subject: [PATCH] Null references to request object on socket errors. Regarding #3199 and #3179 and issues seen in production. Hopefully this fixes them. --- lib/http.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/http.js b/lib/http.js index 4f7aa0a00a..3986709c2a 100644 --- a/lib/http.js +++ b/lib/http.js @@ -1209,6 +1209,13 @@ ClientRequest.prototype.onSocket = function(socket) { // fire on the request. req.emit('error', createHangUpError()); } + + // Nothing more to be done with this req, since the socket + // is closed, and we've emitted the appropriate abort/end/close/error + // events. Disavow all knowledge, and break the references to + // the variables trapped by closures and on the socket object. + req = null; + socket._httpMessage = null; } socket.on('close', closeListener);