From e782a65d24cdaac2645f36b3039c64e5ffd2cfba Mon Sep 17 00:00:00 2001 From: Santiago Gimeno Date: Thu, 26 Nov 2015 22:58:51 +0100 Subject: [PATCH] test: fix tls-no-rsa-key flakiness In some conditions it can happen that the client-side socket is destroyed before the server-side socket has gracefully closed, thus causing a 'ECONNRESET' error in this socket. To solve this, wait in the client-side socket for the 'end' event before closing it. --- test/parallel/test-tls-no-rsa-key.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-tls-no-rsa-key.js b/test/parallel/test-tls-no-rsa-key.js index 61e8a3b7ca3658..ff9806cdb02614 100644 --- a/test/parallel/test-tls-no-rsa-key.js +++ b/test/parallel/test-tls-no-rsa-key.js @@ -23,9 +23,16 @@ var server = tls.createServer(options, function(conn) { var c = tls.connect(common.PORT, { rejectUnauthorized: false }, function() { + c.on('end', common.mustCall(function() { + c.end(); + server.close(); + })); + + c.on('data', function(data) { + assert.equal(data, 'ok'); + }); + cert = c.getPeerCertificate(); - c.destroy(); - server.close(); }); });