Skip to content

Commit d5abdb2

Browse files
committed
fix: switched to increasing the warning limit for only the QUICSocket EventTarget
[ci skip]
1 parent ac46afd commit d5abdb2

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

src/QUICClient.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ import { clientDefault, minIdleTimeout } from './config';
2828
import * as utils from './utils';
2929
import * as events from './events';
3030
import * as errors from './errors';
31-
import nodeEvents from 'events';
32-
nodeEvents.setMaxListeners(1000000);
33-
3431
interface QUICClient extends CreateDestroy {}
3532
@CreateDestroy({
3633
eventDestroy: events.EventQUICClientDestroy,

src/QUICSocket.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import type QUICServer from './QUICServer';
22
import type { Host, Hostname, Port, ResolveHostname } from './types';
33
import type { Header } from './native/types';
4+
import nodesEvents from 'events';
45
import dgram from 'dgram';
56
import Logger from '@matrixai/logger';
67
import { StartStop, ready, running } from '@matrixai/async-init/dist/StartStop';
78
import { utils as errorsUtils } from '@matrixai/errors';
9+
import { _eventTarget } from '@matrixai/events/dist/utils';
810
import QUICConnectionId from './QUICConnectionId';
911
import QUICConnectionMap from './QUICConnectionMap';
1012
import { quiche } from './native';
@@ -247,6 +249,9 @@ class QUICSocket {
247249
reuseAddr?: boolean;
248250
ipv6Only?: boolean;
249251
} = {}): Promise<void> {
252+
// Since we have a one-to-many relationship with clients and connections,
253+
// we want to up the warning limit on the EventTarget
254+
nodesEvents.setMaxListeners(100000, this[_eventTarget]);
250255
let address = utils.buildAddress(host, port);
251256
this.logger.info(`Start ${this.constructor.name} on ${address}`);
252257
// Resolves the host which could be a hostname and acquire the type.

tests/QUICClient.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1935,7 +1935,7 @@ describe(QUICClient.name, () => {
19351935
}
19361936
const clients = await Promise.all(clientPs);
19371937
await connectionEventProm.p;
1938-
await Promise.all(clients.map(client => client.destroy({ force: true })));
1938+
await Promise.all(clients.map((client) => client.destroy({ force: true })));
19391939
await sharedSocket.stop({ force: true });
19401940
await server.stop({ force: true });
19411941
});

0 commit comments

Comments
 (0)