Skip to content

Commit

Permalink
test: deflake test-http2-buffersize
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
lpinca authored and danielleadams committed Aug 16, 2021
1 parent c59e3ec commit 3622fb1
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions test/parallel/test-http2-buffersize.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if (!hasCrypto)
skip('missing crypto');
const assert = require('assert');
const { createServer, connect } = require('http2');
const { once } = require('events');
const Countdown = require('../common/countdown');

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

let client;
const countdown = new Countdown(kSockets, () => {
client.close();
server.close();
});

const getStream = async () => {
const [ stream ] = await once(server, 'stream');
server.on('stream', mustCall((stream) => {
stream.on('data', mustCall());
stream.on('end', mustCall());
stream.on('close', mustCall());
return once(stream, 'close');
};

const promises = [...new Array(kSockets)].map(getStream);
Promise.all(promises).then(mustCall(() => {
client.close();
server.close();
}));
stream.on('close', mustCall(() => {
countdown.dec();
}));
}, kSockets));

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

0 comments on commit 3622fb1

Please sign in to comment.