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 4b43bf0

Browse filesBrowse files
Trottrvagg
authored andcommitted
test: fix flaky test-net-socket-local-address
test-net-socket-local-address had a race condition that resulted in unreliability on FreeBSD and Windows. This changes fixes the issue. Fixes: #2475 PR-URL: #4109 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
1 parent f3417e2 commit 4b43bf0
Copy full SHA for 4b43bf0

File tree

Expand file treeCollapse file tree

2 files changed

+8
-3
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+8
-3
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
@@ -21,4 +21,3 @@ test-child-process-exit-code : PASS,FLAKY
2121
[$system==solaris] # Also applies to SmartOS
2222

2323
[$system==freebsd]
24-
test-net-socket-local-address : PASS,FLAKY
Collapse file

‎test/parallel/test-net-socket-local-address.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-net-socket-local-address.js
+8-2Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ var serverRemotePorts = [];
1515

1616
const server = net.createServer(function(socket) {
1717
serverRemotePorts.push(socket.remotePort);
18-
conns++;
18+
testConnect();
1919
});
2020

2121
const client = new net.Socket();
@@ -29,12 +29,18 @@ server.on('close', common.mustCall(function() {
2929
server.listen(common.PORT, common.localhostIPv4, testConnect);
3030

3131
function testConnect() {
32-
if (conns == 2) {
32+
if (conns > serverRemotePorts.length || conns > clientLocalPorts.length) {
33+
// We're waiting for a callback to fire.
34+
return;
35+
}
36+
37+
if (conns === 2) {
3338
return server.close();
3439
}
3540
client.connect(common.PORT, common.localhostIPv4, function() {
3641
clientLocalPorts.push(this.localPort);
3742
this.once('close', testConnect);
3843
this.destroy();
3944
});
45+
conns++;
4046
}

0 commit comments

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