Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

throw-max-listeners-error

nolanlawson161Apache 21.0.1

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

throw, error, event, eventemitter, node, testing

readme

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.