From 25ba971f41d4ddaf7e241645cfc2917bd3afa1f7 Mon Sep 17 00:00:00 2001 From: Eugene Girshov Date: Mon, 4 Mar 2013 22:44:56 +0200 Subject: http: fix multiple timeout events Fixed up slightly by @isaacs so as not to miss 'timeout' events in some cases. --- lib/http.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'lib/http.js') diff --git a/lib/http.js b/lib/http.js index e057e6baca..50571bf313 100644 --- a/lib/http.js +++ b/lib/http.js @@ -1721,15 +1721,18 @@ ClientRequest.prototype.setTimeout = function(msecs, callback) { return; } + // Set timeoutCb so that it'll get cleaned up on request end + this.timeoutCb = emitTimeout; if (this.socket) { + var sock = this.socket; this.socket.once('connect', function() { - this.setTimeout(msecs, emitTimeout); + sock.setTimeout(msecs, emitTimeout); }); return; } this.once('socket', function(sock) { - this.setTimeout(msecs, emitTimeout); + sock.setTimeout(msecs, emitTimeout); }); }; -- cgit v1.2.3