Skip to content

Commit

Permalink
test: deflake test-tls-close-notify.js
Browse files Browse the repository at this point in the history
This test occasionally fails on macOS with the following error

```
events.js:187
      throw er; // Unhandled 'error' event
      ^

Error: read ECONNRESET
    at TLSWrap.onStreamRead (internal/stream_base_commons.js:201:27)
Emitted 'error' event on TLSSocket instance at:
    at emitErrorNT (internal/streams/destroy.js:84:8)
    at processTicksAndRejections (internal/process/task_queues.js:80:21) {
  errno: -54,
  code: 'ECONNRESET',
  syscall: 'read'
}
```

Fix it by making the client send the close_notify alert instead of the
server.

PR-URL: #30202
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
  • Loading branch information
lpinca authored and targos committed Dec 1, 2019
1 parent cf89100 commit f6498d7
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions test/parallel/test-tls-close-notify.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,18 @@ const server = tls.createServer({
key: fixtures.readKey('agent1-key.pem'),
cert: fixtures.readKey('agent1-cert.pem')
}, function(c) {
// Send close-notify without shutting down TCP socket
const req = new ShutdownWrap();
req.oncomplete = common.mustCall(() => {});
req.handle = c._handle;
c._handle.shutdown(req);
// Ensure that we receive 'end' event anyway.
c.on('end', common.mustCall(function() {
server.close();
}));
}).listen(0, common.mustCall(function() {
const c = tls.connect(this.address().port, {
rejectUnauthorized: false
}, common.mustCall(function() {
// Ensure that we receive 'end' event anyway
c.on('end', common.mustCall(function() {
c.destroy();
server.close();
}));
// Send close-notify without shutting down TCP socket.
const req = new ShutdownWrap();
req.oncomplete = common.mustCall(() => {});
req.handle = c._handle;
c._handle.shutdown(req);
}));
}));

0 comments on commit f6498d7

Please sign in to comment.