Mocha: EventEmitter leak

Created on 4 Dec 2011  路  10Comments  路  Source: mochajs/mocha


  ..........(node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit.
Trace: 
    at Hook.<anonymous> (events.js:133:17)
    at next (/Users/tj/projects/express-resource/node_modules/mocha/lib/runner.js:157:10)
    at Array.0 (/Users/tj/projects/express-resource/node_modules/mocha/lib/runner.js:169:5)
    at EventEmitter._tickCallback (node.js:192:40)
.....

due to the hook error event. we exit currently anyway so it's not a big deal but the warning is annoying

confirmed-bug

Most helpful comment

Not sure if it matters, but I'm getting this error on Mocha 5.0.4

All 10 comments

I'm using the latest version 1.0.1, on node 0.6.8 and getting the same problem:

(node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit.
Trace:
at EventEmitter. (events.js:139:15)
at EventEmitter. (node.js:383:29)
at Runner.run (/Users/sudhirjonathan/projects/liz/node_modules/mocha/lib/runner.js:426:11)
at run (/Users/sudhirjonathan/projects/liz/node_modules/mocha/bin/_mocha:277:10)
at /Users/sudhirjonathan/projects/liz/node_modules/mocha/bin/_mocha:222:7
at /Users/sudhirjonathan/projects/liz/node_modules/mocha/bin/_mocha:263:18
at Array.forEach (native)
at load (/Users/sudhirjonathan/projects/liz/node_modules/mocha/bin/_mocha:258:9)
at loadAndRun (/Users/sudhirjonathan/projects/liz/node_modules/mocha/bin/_mocha:221:5)
at /Users/sudhirjonathan/projects/liz/node_modules/mocha/bin/_mocha:241:5
at StatWatcher. (/Users/sudhirjonathan/projects/liz/node_modules/mocha/lib/utils.js:140:36)
at StatWatcher.emit (events.js:70:17)
at StatWatcher.onchange (fs.js:705:10)

Me too - I'm running:

mocha --compilers coffee:coffee-script -w -G

"mocha": "~1.0.1",
"chai": "~0.5.3",
"node-dev": "~0.2.2"

The stack trace I get is:

(node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit.
Trace:
at EventEmitter. (events.js:139:15)
at EventEmitter. (node.js:389:29)
at Runner.run (/usr/local/lib/node_modules/mocha/lib/runner.js:426:11)
at run (/usr/local/lib/node_modules/mocha/bin/_mocha:277:10)
at /usr/local/lib/node_modules/mocha/bin/_mocha:222:7
at /usr/local/lib/node_modules/mocha/bin/_mocha:263:18
at Array.forEach (native)
at load (/usr/local/lib/node_modules/mocha/bin/_mocha:258:9)
at loadAndRun (/usr/local/lib/node_modules/mocha/bin/_mocha:221:5)
at /usr/local/lib/node_modules/mocha/bin/_mocha:241:5
at StatWatcher. (/usr/local/lib/node_modules/mocha/lib/utils.js:140:36)
at StatWatcher.emit (events.js:70:17)
at StatWatcher.onchange (fs.js:705:10)

I wonder if this is a node_dev thing - does the restart release all of the resources?

Ping me if I can be of any help.

Ben

I'm getting this issue with mocha 1.2.2

I was getting this issue when using the '--watch' flag in 1.3.2, and upgrading to 1.6.0 resolved it for me. For anyone still experiencing the problem, I recommend updating mocha.

i am getting same error on version : 1.18.2

(node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit.
Trace:
  at process.EventEmitter.addListener (events.js:160:15)
  at process.on.process.addListener (node.js:769:26)
  at Runner.run (/home/safareli/Web/audioviz/node_modules/mocha/lib/runner.js:588:11)
  at Mocha.run (/home/safareli/Web/audioviz/node_modules/mocha/lib/mocha.js:369:17)
  at Transform._flush (/home/safareli/Web/audioviz/node_modules/gulp-mocha/index.js:21:10)
  at Transform.<anonymous> (/home/safareli/Web/audioviz/node_modules/gulp-mocha/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:135:12)
  at Transform.g (events.js:180:16)
  at Transform.EventEmitter.emit (events.js:117:20)
  at finishMaybe (/home/safareli/Web/audioviz/node_modules/gulp-mocha/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:372:12)
  at endWritable (/home/safareli/Web/audioviz/node_modules/gulp-mocha/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:379:3)
  at Transform.Writable.end (/home/safareli/Web/audioviz/node_modules/gulp-mocha/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:357:5)
  at Transform.onend (/home/safareli/Web/audioviz/node_modules/gulp-cached/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:505:10)
  at Transform.g (events.js:180:16)
  at Transform.EventEmitter.emit (events.js:117:20)
  at /home/safareli/Web/audioviz/node_modules/gulp-cached/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:942:16
  at process._tickCallback (node.js:415:13)

Awesome.. this is still around 2 years later and hasn't been addressed. I'm on 2.2.5 and I'm seeing the same error, which is causing my test server to skip tests... Can we get this addressed?

@RavenHursT sure! My rate is $150/hr.

Maybe it hasn't been addressed because it was closed, and nobody sent any sort of reproduction plan. So, you could start there. otherwise I'm afraid your chances are slim-to-none

Not sure if it matters, but I'm getting this error on Mocha 5.0.4

This warning also appears in Mocha 5.2.0.

if someone has a MCVE, please provide one in a new issue. Locking this issue.

Was this page helpful?
0 / 5 - 0 ratings