diff --git a/test/parallel/test-cluster-dgram-2.js b/test/parallel/test-cluster-dgram-2.js index 179b1ee15327e7..863e0fa358c73e 100644 --- a/test/parallel/test-cluster-dgram-2.js +++ b/test/parallel/test-cluster-dgram-2.js @@ -57,6 +57,13 @@ function worker() { // send(), explicitly bind them to an ephemeral port. socket.bind(0); - for (var i = 0; i < PACKETS_PER_WORKER; i++) + // There is no guarantee that a sent dgram packet will be received so keep + // sending until disconnect. + const interval = setInterval(() => { socket.send(buf, 0, buf.length, common.PORT, '127.0.0.1'); + }, 1); + + cluster.worker.on('disconnect', () => { + clearInterval(interval); + }); }