Skip to content

Commit 3622fb1

Browse files
lpincadanielleadams
authored andcommitted
test: deflake test-http2-buffersize
This is basically a revert of c452632. The problem with that commit is that the promises returned by `once(server, 'stream')` are all resolved with the same stream when the first `'stream'` event is emitted. Refs: #39525 (comment) PR-URL: #39591 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
1 parent c59e3ec commit 3622fb1

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

test/parallel/test-http2-buffersize.js

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ if (!hasCrypto)
55
skip('missing crypto');
66
const assert = require('assert');
77
const { createServer, connect } = require('http2');
8-
const { once } = require('events');
8+
const Countdown = require('../common/countdown');
99

1010
// This test ensures that `bufferSize` of Http2Session and Http2Stream work
1111
// as expected.
@@ -16,20 +16,18 @@ const { once } = require('events');
1616
const server = createServer();
1717

1818
let client;
19+
const countdown = new Countdown(kSockets, () => {
20+
client.close();
21+
server.close();
22+
});
1923

20-
const getStream = async () => {
21-
const [ stream ] = await once(server, 'stream');
24+
server.on('stream', mustCall((stream) => {
2225
stream.on('data', mustCall());
2326
stream.on('end', mustCall());
24-
stream.on('close', mustCall());
25-
return once(stream, 'close');
26-
};
27-
28-
const promises = [...new Array(kSockets)].map(getStream);
29-
Promise.all(promises).then(mustCall(() => {
30-
client.close();
31-
server.close();
32-
}));
27+
stream.on('close', mustCall(() => {
28+
countdown.dec();
29+
}));
30+
}, kSockets));
3331

3432
server.listen(0, mustCall(() => {
3533
const authority = `http://localhost:${server.address().port}`;

0 commit comments

Comments
 (0)