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 a256790

Browse filesBrowse files
mscdexMyles Borins
authored andcommitted
test: fix flaky cluster-net-send
Before this commit, it was possible on Windows for the server's 'connection' handler to be called *after* the client socket's 'connect' handler. This caused the 'message' event to be missed and the test would never end (timing out in CI). This problem was more easily reproducible on a low resource (slow CPU) Windows (2012r2) installation. This commit waits until both handlers have been called before sending the handle to the master process. Fixes: #3957 PR-URL: #4444 Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent 6809c2b commit a256790
Copy full SHA for a256790

File tree

Expand file treeCollapse file tree

2 files changed

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

2 files changed

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

‎test/parallel/parallel.status‎

Copy file name to clipboardExpand all lines: test/parallel/parallel.status
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ prefix parallel
77
[true] # This section applies to all platforms
88

99
[$system==win32]
10-
test-cluster-net-send : PASS,FLAKY
1110
test-cluster-shared-leak : PASS,FLAKY
1211
test-debug-no-context : PASS,FLAKY
1312
test-tls-ticket-cluster : PASS,FLAKY
Collapse file

‎test/parallel/test-cluster-net-send.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-cluster-net-send.js
+9-3Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,22 @@ if (process.argv[2] !== 'child') {
3131
} else {
3232
console.error('[%d] worker', process.pid);
3333

34+
var socket;
35+
var cbcalls = 0;
36+
function socketConnected() {
37+
if (++cbcalls === 2)
38+
process.send('handle', socket);
39+
}
40+
3441
var server = net.createServer(function(c) {
3542
process.once('message', function(msg) {
3643
assert.equal(msg, 'got');
3744
c.end('hello');
3845
});
46+
socketConnected();
3947
});
4048
server.listen(common.PORT, function() {
41-
var socket = net.connect(common.PORT, '127.0.0.1', function() {
42-
process.send('handle', socket);
43-
});
49+
socket = net.connect(common.PORT, '127.0.0.1', socketConnected);
4450
});
4551

4652
process.on('disconnect', function() {

0 commit comments

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