From 5973332f80d0817426d38a7fe5ab1b39d2057a1c Mon Sep 17 00:00:00 2001 From: Alba Mendez Date: Tue, 30 Jul 2019 22:06:46 +0200 Subject: [PATCH] test: fix race in test-http2-origin --- test/parallel/test-http2-origin.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/test/parallel/test-http2-origin.js b/test/parallel/test-http2-origin.js index 7aa0a16e35f22e..6f90a043d8a7cc 100644 --- a/test/parallel/test-http2-origin.js +++ b/test/parallel/test-http2-origin.js @@ -88,7 +88,7 @@ const ca = readKey('fake-startcom-root-cert.pem', 'binary'); ['https://example.org', 'https://example.com'] ]; - const countdown = new Countdown(2, () => { + const countdown = new Countdown(3, () => { client.close(); server.close(); }); @@ -101,7 +101,7 @@ const ca = readKey('fake-startcom-root-cert.pem', 'binary'); countdown.dec(); }, 2)); - client.request().on('close', mustCall()).resume(); + client.request().on('close', mustCall(() => countdown.dec())).resume(); })); } @@ -119,15 +119,19 @@ const ca = readKey('fake-startcom-root-cert.pem', 'binary'); const originSet = [`https://localhost:${server.address().port}`]; const client = connect(originSet[0], { ca }); + const countdown = new Countdown(2, () => { + client.close(); + server.close(); + }); + client.on('origin', mustCall((origins) => { originSet.push(...check); deepStrictEqual(client.originSet, originSet); deepStrictEqual(origins, check); - client.close(); - server.close(); + countdown.dec(); })); - client.request().on('close', mustCall()).resume(); + client.request().on('close', mustCall(() => countdown.dec())).resume(); })); }