Skip to content

Standardise increasing the event limit for events #105

Open
@tegefaulkes

Description

@tegefaulkes

Specification

Right now in certain cases we have an EventTarget or a AbortSignal which has many registered listeners. Usually when multiple children classes need to listen to a parent. EG, multiple QUICConnections per QUICServer, or multiple QUICStreams per QUICConnection. By default, when we exceed 11 listeners we get the following warning.

> (node:61422) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 foo listeners added to [EventEmitter]. Use emitter.setMaxListeners() to increase limit

Currently this has been addressed in two locations with the following.

QUICServer.ts 379: nodesEvents.setMaxListeners(100000, this.stopAbortController.signal); QUICSocket.ts 254: nodesEvents.setMaxListeners(100000, this[_eventTarget]);

But we want to standardise how this is generally done and avoid magic numbers in random places in the code. The limit should also configurable in some way. At the very least the nodesEvents.setMaxListeners should be moved into a utility function to avoid spreading out the magic.

Additional context

Relevant discussion: https://github.com/MatrixAI/js-quic/pull/104/files#r1626356768

Tasks

  1. The nodesEvents.setMaxListeners usage should be standardised and quarantined into a utility function.
  2. The limit should come from a config parameter in some way.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions