From f78ecc3f939b37f3d91346b5995e42e9b2dec793 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 Backport-PR-URL: https://github.com/nodejs/node/pull/28904 PR-URL: https://github.com/nodejs/node/pull/28903 Reviewed-By: Anna Henningsen Reviewed-By: Rich Trott --- 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 b06d371e29f36d..1d3bc0f99bb8a2 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(originSet, client.originSet); deepStrictEqual(origins, check); - client.close(); - server.close(); + countdown.dec(); })); - client.request().on('close', mustCall()).resume(); + client.request().on('close', mustCall(() => countdown.dec())).resume(); })); }