mirror of
https://github.com/nodejs/node.git
synced 2025-12-28 07:50:41 +00:00
test: deflake test-http2-buffersize
This is basically a revert of
c452632d34.
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: https://github.com/nodejs/node/pull/39525#issuecomment-889080913
PR-URL: https://github.com/nodejs/node/pull/39591
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
This commit is contained in:
parent
f2d02ab81a
commit
0f9434af4d
@ -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.
|
||||
@ -16,20 +16,18 @@ const { once } = require('events');
|
||||
const server = createServer();
|
||||
|
||||
let client;
|
||||
|
||||
const getStream = async () => {
|
||||
const [ stream ] = await once(server, '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(() => {
|
||||
const countdown = new Countdown(kSockets, () => {
|
||||
client.close();
|
||||
server.close();
|
||||
}));
|
||||
});
|
||||
|
||||
server.on('stream', mustCall((stream) => {
|
||||
stream.on('data', mustCall());
|
||||
stream.on('end', mustCall());
|
||||
stream.on('close', mustCall(() => {
|
||||
countdown.dec();
|
||||
}));
|
||||
}, kSockets));
|
||||
|
||||
server.listen(0, mustCall(() => {
|
||||
const authority = `http://localhost:${server.address().port}`;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user