Skip to content

Commit

Permalink
test: fix race in test-http2-origin
Browse files Browse the repository at this point in the history
Backport-PR-URL: #28904
PR-URL: #28903
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
  • Loading branch information
mildsunrise authored and BethGriggs committed Oct 7, 2019
1 parent 56a834a commit f78ecc3
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions test/parallel/test-http2-origin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Expand All @@ -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();
}));
}

Expand All @@ -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();
}));
}

Expand Down

0 comments on commit f78ecc3

Please sign in to comment.