From ed080d868db664d8e539acbbcc93ff90a7a20585 Mon Sep 17 00:00:00 2001 From: Luigi Pinca Date: Fri, 19 Apr 2024 05:17:19 -0400 Subject: [PATCH] test: ensure that all worker servers are ready MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Wait for the `'listening'` message from all workers before creating the first connection. This fixes an `EMFILE` error that is raised on Windows when running the following command ``` python tools/test.py -J --repeat=1000 parallel/test-tls-ticket-cluster ``` PR-URL: https://github.com/nodejs/node/pull/52563 Reviewed-By: Michaƫl Zasso Reviewed-By: Marco Ippolito Reviewed-By: Yagiz Nizipli Reviewed-By: Benjamin Gruenbaum --- test/parallel/test-tls-ticket-cluster.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/test/parallel/test-tls-ticket-cluster.js b/test/parallel/test-tls-ticket-cluster.js index 746b8533147f54..628b2fcd6a9661 100644 --- a/test/parallel/test-tls-ticket-cluster.js +++ b/test/parallel/test-tls-ticket-cluster.js @@ -33,10 +33,10 @@ const workerCount = 4; const expectedReqCount = 16; if (cluster.isPrimary) { + let listeningCount = 0; let reusedCount = 0; let reqCount = 0; let lastSession = null; - let shootOnce = false; let workerPort = null; function shoot() { @@ -73,9 +73,8 @@ if (cluster.isPrimary) { console.error('[primary] got %j', msg); if (msg === 'reused') { ++reusedCount; - } else if (msg === 'listening' && !shootOnce) { - workerPort = port || workerPort; - shootOnce = true; + } else if (msg === 'listening' && ++listeningCount === workerCount) { + workerPort = port; shoot(); } });