Skip to content

nolanlawson/throw-max-listeners-error

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

throw-max-listeners-error

Build Status

Throw an error if any EventEmitter exceeds its maximum number of listeners for any event. Useful for testing memory leaks.

Usage

$ npm install throw-max-listeners-error --save
require('throw-max-listeners-error');

Description

Have you ever seen this error in a Node module before?

(node) warning: possible EventEmitter memory leak detected.
  11 listeners added. Use emitter.setMaxListeners() to increase limit.

Okay, that's pretty cool! It's nice to get a warning when we've got too many listeners.

But for testing purposes, wouldn't it be better if it just threw an error? Then you could actually guarantee in your tests that the number of max listeners was never reached.

That's exactly what this thing does. Just require() it and you're done; every EventEmitter will throw an error if its max number of listeners is reached.

About

Throw an error if the max number of EventEmitter listeners is exceeded

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •