From 5b02d564c31fffb13f1749a4734e5dd4dc9654c0 Mon Sep 17 00:00:00 2001 From: Stefan Rusu Date: Thu, 14 Jul 2011 15:33:04 +0300 Subject: [PATCH] Fixes #1085. The agent end event may call detachSocket() after the socket is detached and destroyed by abort(). This patch avoids that behavior. --- lib/http.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/http.js b/lib/http.js index 3bb24cbef77..14befd15dfe 100644 --- a/lib/http.js +++ b/lib/http.js @@ -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);