Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSantiago Gimeno <santiago.gimeno@gmail.com>2017-03-10 14:13:49 +0300
committerItalo A. Casas <me@italoacasas.com>2017-03-14 17:01:56 +0300
commit734ddbe77b4de991c8547a78331f5e4eb06cc0a5 (patch)
tree4cd3c321ae5f0249434606dccba5caeef39d2e59 /test
parent757bf484ff3390605246491545267f32ffb45804 (diff)
test: fix flaky test-http-set-timeout-server
It can happen that the connection and server is closed before the second reponse has been processed by server. In this case, the `res.setTimeout()` callback will never be called causing the test to fail. Fix this by only closing the connection and server when the 2nd has been received. PR-URL: https://github.com/nodejs/node/pull/11790 Fixes: https://github.com/nodejs/node/issues/11768 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-http-set-timeout-server.js11
1 files changed, 8 insertions, 3 deletions
diff --git a/test/parallel/test-http-set-timeout-server.js b/test/parallel/test-http-set-timeout-server.js
index 097aeb260bd..8f301af5a9d 100644
--- a/test/parallel/test-http-set-timeout-server.js
+++ b/test/parallel/test-http-set-timeout-server.js
@@ -117,10 +117,13 @@ test(function serverRequestNotTimeoutAfterEnd(cb) {
test(function serverResponseTimeoutWithPipeline(cb) {
let caughtTimeout = '';
+ let secReceived = false;
process.on('exit', function() {
assert.strictEqual(caughtTimeout, '/2');
});
const server = http.createServer(function(req, res) {
+ if (req.url === '/2')
+ secReceived = true;
const s = res.setTimeout(50, function() {
caughtTimeout += req.url;
});
@@ -128,9 +131,11 @@ test(function serverResponseTimeoutWithPipeline(cb) {
if (req.url === '/1') res.end();
});
server.on('timeout', function(socket) {
- socket.destroy();
- server.close();
- cb();
+ if (secReceived) {
+ socket.destroy();
+ server.close();
+ cb();
+ }
});
server.listen(common.mustCall(function() {
const port = server.address().port;