From 44003306c67abf6b3e0d7025eb7de60c2d786448 Mon Sep 17 00:00:00 2001 From: Eran Hammer Date: Wed, 28 Aug 2013 11:37:21 -0700 Subject: [PATCH] node 0.11 fixes --- lib/payload.js | 5 +++-- lib/response/stream.js | 4 ---- test/integration/clientTimeout.js | 8 +++----- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/lib/payload.js b/lib/payload.js index 6418902f4..b9f46747d 100755 --- a/lib/payload.js +++ b/lib/payload.js @@ -62,11 +62,12 @@ exports.read = function (request, next) { var clientTimeoutId = null; if (clientTimeout) { - clientTimeout -= Date.now() - request._timestamp; + clientTimeout -= (Date.now() - request._timestamp); + clientTimeoutId = setTimeout(function () { finish(Boom.clientTimeout('Client is taking too long to send request')); - }, clientTimeout); + }, clientTimeout < 0 ? 0 : clientTimeout); } // Return only once from events diff --git a/lib/response/stream.js b/lib/response/stream.js index de591ab6f..b021ec78b 100755 --- a/lib/response/stream.js +++ b/lib/response/stream.js @@ -173,10 +173,6 @@ internals.Stream.prototype._transmit = function (request, callback) { }); self._preview.end(); - - if (self._stream.destroy) { - self._stream.destroy(); - } } }; diff --git a/test/integration/clientTimeout.js b/test/integration/clientTimeout.js index 5d9cda2cf..80f2b40e3 100755 --- a/test/integration/clientTimeout.js +++ b/test/integration/clientTimeout.js @@ -82,7 +82,6 @@ describe('Client Timeout', function () { method: 'POST' }; - var req = Http.request(options, function (res) { expect(res.statusCode).to.equal(408); @@ -90,11 +89,10 @@ describe('Client Timeout', function () { done(); }); - req.on('error', function (err) { // Will error out, so don't allow error to escape test - - }); + req.on('error', function (err) { }); // Will error out, so don't allow error to escape test - req.write('\n'); + req.write('{}\n'); + var now = Date.now(); setTimeout(function () { req.end();