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 37cc249

Browse filesBrowse files
santigimenoMyles Borins
authored andcommitted
test: fix test-net-settimeout flakiness
Wait for the data to be received by the socket before creating the clean-up timer. This way, a possible (though unlikely) `ECONNRESET` error can be avoided. PR-URL: #6166 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
1 parent 69dcbb6 commit 37cc249
Copy full SHA for 37cc249

File tree

Expand file treeCollapse file tree

1 file changed

+11
-9
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+11
-9
lines changed
Open diff view settings
Collapse file

‎test/parallel/test-net-settimeout.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-net-settimeout.js
+11-9Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,24 @@ const assert = require('assert');
88

99
const T = 100;
1010

11-
const server = net.createServer(function(c) {
11+
const server = net.createServer(common.mustCall((c) => {
1212
c.write('hello');
13-
});
13+
}));
14+
1415
server.listen(common.PORT);
1516

1617
const socket = net.createConnection(common.PORT, 'localhost');
1718

18-
const s = socket.setTimeout(T, function() {
19+
const s = socket.setTimeout(T, () => {
1920
common.fail('Socket timeout event is not expected to fire');
2021
});
2122
assert.ok(s instanceof net.Socket);
2223

23-
socket.setTimeout(0);
24-
25-
setTimeout(function() {
26-
socket.destroy();
27-
server.close();
28-
}, T * 2);
24+
socket.on('data', common.mustCall(() => {
25+
setTimeout(function() {
26+
socket.destroy();
27+
server.close();
28+
}, T * 2);
29+
}));
2930

31+
socket.setTimeout(0);

0 commit comments

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