Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4d27930

Browse filesBrowse files
Trottaddaleax
authored andcommitted
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: #13529 Fixes: #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>
1 parent 3da56ac commit 4d27930
Copy full SHA for 4d27930

File tree

Expand file treeCollapse file tree

1 file changed

+16
-5
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+16
-5
lines changed
Open diff view settings
Collapse file

‎test/parallel/test-tls-socket-close.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-tls-socket-close.js
+16-5Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,17 @@ const netServer = net.createServer((socket) => {
3232

3333
netSocket = socket;
3434
}).listen(0, common.mustCall(function() {
35-
// connect client
36-
tls.connect({
35+
connectClient(netServer);
36+
}));
37+
38+
function connectClient(server) {
39+
const tlsConnection = tls.connect({
3740
host: 'localhost',
38-
port: this.address().port,
41+
port: server.address().port,
3942
rejectUnauthorized: false
40-
}).write('foo', 'utf8', common.mustCall(() => {
43+
});
44+
45+
tlsConnection.write('foo', 'utf8', common.mustCall(() => {
4146
assert(netSocket);
4247
netSocket.setTimeout(1, common.mustCall(() => {
4348
assert(tlsSocket);
@@ -55,4 +60,10 @@ const netServer = net.createServer((socket) => {
5560
}, 1);
5661
}));
5762
}));
58-
}));
63+
tlsConnection.on('error', (e) => {
64+
// Tolerate the occasional ECONNRESET.
65+
// Ref: https://github.com/nodejs/node/issues/13184
66+
if (e.code !== 'ECONNRESET')
67+
throw e;
68+
});
69+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.