diff --git a/test/common.js b/test/common.js index 2030bede51..091fcebdd4 100644 --- a/test/common.js +++ b/test/common.js @@ -91,8 +91,9 @@ HTTPClient.prototype.request = function (path, opts, fn) { */ HTTPClient.prototype.end = function () { - this.agent.sockets.forEach(function (socket) { - socket.end(); + var self = this; + Object.keys(this.agent.sockets).forEach(function (socket) { + self.agent.sockets[socket][0]._handle.socket.end(); }); };