You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 17, 2021. It is now read-only.
Sets the max listener count for the EventEmitter. When the count of listeners for an event exceeds this limit a warning will be printed. Set to 0 for no limit. The default limit is 10.
Arguments
EventEmitter.setMaxListeners(maxListeners);
Number maxListeners The new max listener limit
Returns
Object The current EventEmitter instance to allow chaining
Notes
The warning will only be shown once, it will appear in the console. You can check if a warning has already been shown with the following code.
ee._events.{event type}.warned;
Obviously replace {event type} with a string such as speak.
Examples
var ee = new EventEmitter(),
i = null;
for(i = 0; i < 100; i += 1) {
ee.on('foo', function() {
// Empty function
});
}
// This will be logged:
// Possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit.