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);