mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
bcf11356b3
PR-URL: https://github.com/nodejs/node/pull/27987 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com>
42 lines
1.1 KiB
JavaScript
42 lines
1.1 KiB
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
if (!common.hasCrypto)
|
|
common.skip('missing crypto');
|
|
const http2 = require('http2');
|
|
const EventEmitter = require('events');
|
|
|
|
// This test ensures that a MaxListenersExceededWarning isn't emitted if
|
|
// more than EventEmitter.defaultMaxListeners requests are started on a
|
|
// ClientHttp2Session before it has finished connecting.
|
|
|
|
process.on('warning', common.mustNotCall('A warning was emitted'));
|
|
|
|
const server = http2.createServer();
|
|
server.on('stream', (stream) => {
|
|
stream.respond();
|
|
stream.end();
|
|
});
|
|
|
|
server.listen(common.mustCall(() => {
|
|
const client = http2.connect(`http://localhost:${server.address().port}`);
|
|
|
|
function request() {
|
|
return new Promise((resolve, reject) => {
|
|
const stream = client.request();
|
|
stream.on('error', reject);
|
|
stream.on('response', resolve);
|
|
stream.end();
|
|
});
|
|
}
|
|
|
|
const requests = [];
|
|
for (let i = 0; i < EventEmitter.defaultMaxListeners + 1; i++) {
|
|
requests.push(request());
|
|
}
|
|
|
|
Promise.all(requests).then(common.mustCall()).finally(common.mustCall(() => {
|
|
server.close();
|
|
client.close();
|
|
}));
|
|
}));
|