Fixes #1085. The agent end event may call detachSocket() after the socket is detached...
authorStefan Rusu <saltwaterc@gmail.com>
Thu, 14 Jul 2011 12:33:04 +0000 (15:33 +0300)
committerkoichik <koichik@improvement.jp>
Thu, 14 Jul 2011 15:33:28 +0000 (00:33 +0900)
lib/http.js

index 3bb24cb..14befd1 100644 (file)
@@ -1333,7 +1333,10 @@ Agent.prototype._establishNewConnection = function() {
         debug('AGENT socket keep-alive');
       }
 
-      req.detachSocket(socket);
+      // The socket may already be detached and destroyed by an abort call
+      if (socket._httpMessage) {
+        req.detachSocket(socket);
+      }
 
       assert(!socket._httpMessage);