Null references to request object on socket errors.
authorisaacs <i@izs.me>
Tue, 1 May 2012 21:26:18 +0000 (14:26 -0700)
committerisaacs <i@izs.me>
Fri, 4 May 2012 21:27:24 +0000 (14:27 -0700)
Regarding #3199 and #3179 and issues seen in production.
Hopefully this fixes them.

lib/http.js

index a3f7118..be2af54 100644 (file)
@@ -1361,6 +1361,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);