Skip to content

Commit

Permalink
test: fix test-cluster-dgram-1 flakiness
Browse files Browse the repository at this point in the history
Check for the number of messages received in the `exit` event listener
instead of the `disconnect` listener.

Fixes: #8380
PR-URL: #8383
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
Reviewed By: James M Snell <[email protected]>
  • Loading branch information
santigimeno authored and Fishrock123 committed Sep 9, 2016
1 parent 6d421a2 commit f0300ed
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions test/parallel/test-cluster-dgram-1.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,10 @@ function master() {

worker.on('message', common.mustCall((msg) => {
received = msg.received;
worker.disconnect();
}));

worker.on('disconnect', common.mustCall(() => {
worker.on('exit', common.mustCall(() => {
assert.strictEqual(received, PACKETS_PER_WORKER);
}));
}
Expand All @@ -85,7 +86,7 @@ function worker() {
// Every 10 messages, notify the master.
if (received === PACKETS_PER_WORKER) {
process.send({received: received});
process.disconnect();
socket.close();
}
}, PACKETS_PER_WORKER));

Expand Down

0 comments on commit f0300ed

Please sign in to comment.