diff options
author | Rich Trott <rtrott@gmail.com> | 2017-06-07 12:43:22 -0700 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2017-06-09 22:30:43 -0700 |
commit | dde4f0f1bfa0471daf8001f97f21ddb2b21db047 (patch) | |
tree | d96b49d12e6444917d7505b6c32cd5ce994416ba /test/parallel/test-tls-socket-close.js | |
parent | c9d45c4505a35e974c1c4b56f2ed699f2694aa14 (diff) | |
download | android-node-v8-dde4f0f1bfa0471daf8001f97f21ddb2b21db047.tar.gz android-node-v8-dde4f0f1bfa0471daf8001f97f21ddb2b21db047.tar.bz2 android-node-v8-dde4f0f1bfa0471daf8001f97f21ddb2b21db047.zip |
test: fix flaky test-tls-socket-close
Add error listener to ignore `ECONNRESET`. Makes test reliable while it
still segfaults (as expected) on Node.js 7.7.3. It might not be possible
to eliminate the probable race causing `ECONNRESET` without also
eliminating the required segfault-inducing part of the test. (Or maybe
it's totally possible. If you figure it out, hey cool, submit a pull
request.)
PR-URL: https://github.com/nodejs/node/pull/13529
Fixes: https://github.com/nodejs/node/issues/13184
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test/parallel/test-tls-socket-close.js')
-rw-r--r-- | test/parallel/test-tls-socket-close.js | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/test/parallel/test-tls-socket-close.js b/test/parallel/test-tls-socket-close.js index a5d7410f49..25282ada9e 100644 --- a/test/parallel/test-tls-socket-close.js +++ b/test/parallel/test-tls-socket-close.js @@ -32,12 +32,17 @@ const netServer = net.createServer((socket) => { netSocket = socket; }).listen(0, common.mustCall(function() { - // connect client - tls.connect({ + connectClient(netServer); +})); + +function connectClient(server) { + const tlsConnection = tls.connect({ host: 'localhost', - port: this.address().port, + port: server.address().port, rejectUnauthorized: false - }).write('foo', 'utf8', common.mustCall(() => { + }); + + tlsConnection.write('foo', 'utf8', common.mustCall(() => { assert(netSocket); netSocket.setTimeout(1, common.mustCall(() => { assert(tlsSocket); @@ -55,4 +60,10 @@ const netServer = net.createServer((socket) => { }, 1); })); })); -})); + tlsConnection.on('error', (e) => { + // Tolerate the occasional ECONNRESET. + // Ref: https://github.com/nodejs/node/issues/13184 + if (e.code !== 'ECONNRESET') + throw e; + }); +} |