From 4f7594b8dfa8861ab196cfc4f14f56a6d67d476c Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sun, 31 Jul 2016 08:59:58 -0700 Subject: [PATCH] test: fix flaky test-tls-wrap-timeout Fixes: https://github.com/nodejs/node/issue/7650 --- test/parallel/test-tls-wrap-timeout.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/test/parallel/test-tls-wrap-timeout.js b/test/parallel/test-tls-wrap-timeout.js index ab0f307a970bb3..2cf200d0321719 100644 --- a/test/parallel/test-tls-wrap-timeout.js +++ b/test/parallel/test-tls-wrap-timeout.js @@ -17,18 +17,18 @@ var options = { }; var server = tls.createServer(options, function(c) { - setTimeout(function() { + setImmediate(function() { c.write('hello'); - setTimeout(function() { + setImmediate(function() { c.destroy(); server.close(); - }, 150); - }, 150); + }); + }); }); server.listen(0, function() { var socket = net.connect(this.address().port, function() { - var s = socket.setTimeout(common.platformTimeout(240), function() { + var s = socket.setTimeout(common.platformTimeout(100), function() { throw new Error('timeout'); }); assert.ok(s instanceof net.Socket); @@ -40,3 +40,6 @@ server.listen(0, function() { tsocket.resume(); }); }); + +// hold event loop open long enough to make sure socket timeout does not fire +setTimeout(function() {}, common.platformTimeout(300));