-
I think it'd be great to have a programmatic way of disabling the const ac = new AbortController();
for (let i = 0; i < 100; i++ ) {
ac.signal.addEventListener("abort", e => undefined);
} Running this (runkit) produces a warning:
There is no Maybe we should not have this warning on for
This way the code could be shared between browsers and Node without mods. Thanks again @addaleax and the team for adding |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
const {
setMaxListeners,
EventEmitter
} = require('events');
const target = new EventTarget();
const emitter = new EventEmitter();
setMaxListeners(5, target, emitter); |
Beta Was this translation helpful? Give feedback.
-
For the sake of completeness here is the code for const { setMaxListeners } = require('events')
const ac = new AbortController()
const { signal } = ac
// our signal is perhaps going to have 100 listeners (101st listener will again produce a warning)
setMaxListeners(100, signal)
for (let i = 0; i < 100; i++ ) {
signal.addEventListener('abort', () => {})
} |
Beta Was this translation helpful? Give feedback.
See: https://nodejs.org/dist/latest-v15.x/docs/api/events.html#events_eventemitter_setmaxlisteners_n_eventtargets