From 3b94991bda0922af09b00c2338f364d901678aad Mon Sep 17 00:00:00 2001 From: Santiago Gimeno Date: Tue, 8 Dec 2015 14:57:22 +0100 Subject: [PATCH] test: fix tls-inception flakiness When sending a very large buffer (400000 bytes) the test fails due to the client socket from the `a` server erroring with `ECONNRESET`. There's a race condition between the closing of this socket and the `ssl` socket closing on the other side of the connection. To improve things, destroy the socket as soon as possible: in the `end` event of the `dest` socket. PR-URL: https://github.com/nodejs/node/pull/4195 Reviewed-By: Brian White Reviewed-By: Fedor Indutny --- test/parallel/test-tls-inception.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-tls-inception.js b/test/parallel/test-tls-inception.js index bf8688fdd2..8946f52bdd 100644 --- a/test/parallel/test-tls-inception.js +++ b/test/parallel/test-tls-inception.js @@ -14,7 +14,7 @@ var net = require('net'); var options, a, b; -var body = new Buffer(4000).fill('A'); +var body = new Buffer(400000).fill('A'); options = { key: fs.readFileSync(path.join(common.fixturesDir, 'test_key.pem')), @@ -32,7 +32,7 @@ a = tls.createServer(options, function(socket) { dest.pipe(socket); socket.pipe(dest); - dest.on('close', function() { + dest.on('end', function() { socket.destroy(); }); });