Open tegefaulkes opened 3 months ago
This was addressed by the recent commit 0d7bc46663abfeb8dab0275fed412b0ca1384eec
This:
/**
* Increases the total number of registered event handlers before a node warning is emitted.
* In most cases this is not needed but in the case where you have one event emitter for multiple handlers you'll need
* to increase the limit.
* @param target - The specific `EventTarget` or `EventEmitter` to increase the warning for.
* @param limit - The limit before the warning is emitted, defaults to 100000.
*/
function setMaxListeners(
target: EventTarget | NodeJS.EventEmitter,
limit: number = 100000,
) {
events.setMaxListeners(limit, target);
}
The number there needs to be part of the system configuration config.ts
whether in js-quic
or in Polykey... etc. It's a magic number and magic numbers must be lifted to be explicit.
Ok, I'll make the change.
Specification
Right now in certain cases we have an
EventTarget
or aAbortSignal
which has many registered listeners. Usually when multiple children classes need to listen to a parent. EG, multipleQUICConnection
s perQUICServer
, or multipleQUICStream
s perQUICConnection
. By default, when we exceed 11 listeners we get the following warning.Currently this has been addressed in two locations with the following.
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
nodesEvents.setMaxListeners
usage should be standardised and quarantined into a utility function.