Skip to content

Commit aebc8df

Browse files
Trottaddaleax
authored andcommitted
test: fix flaky test-cluster-dgram-2
There is no guarantee that a dgram packet will be received. The test is currently written to only send exactly as many dgram packets as required assuming they are all received. As a result, failures like this may occur (from CI): ``` not ok 719 parallel/test-cluster-dgram-2 --- duration_ms: 120.39 severity: fail stack: |- timeout ``` This change has the workers send packets continuously until disconnect. PR-URL: nodejs#9791 Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
1 parent 5542a72 commit aebc8df

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

test/parallel/test-cluster-dgram-2.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@ function worker() {
5757
// send(), explicitly bind them to an ephemeral port.
5858
socket.bind(0);
5959

60-
for (var i = 0; i < PACKETS_PER_WORKER; i++)
60+
// There is no guarantee that a sent dgram packet will be received so keep
61+
// sending until disconnect.
62+
const interval = setInterval(() => {
6163
socket.send(buf, 0, buf.length, common.PORT, '127.0.0.1');
64+
}, 1);
65+
66+
cluster.worker.on('disconnect', () => {
67+
clearInterval(interval);
68+
});
6269
}

0 commit comments

Comments
 (0)