question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

(3.6.2) Maximum event emitters exceeded

See original GitHub issue

We started evaluating gulp for migrating a big JS project to and ran into the following problem:

(node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit.
Trace
    at StatWatcher.EventEmitter.addListener (events.js:176:15)
    at Object.fs.watchFile (fs.js:1142:8)
    at Gaze._pollFile (/Users/joscha/jimdo/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-watcher/node_modules/gaze/lib/gaze.js:329:10)
    at /Users/joscha/jimdo/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-watcher/node_modules/gaze/lib/gaze.js:411:12
    at Array.forEach (native)
    at /Users/joscha/jimdo/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-watcher/node_modules/gaze/lib/gaze.js:409:11
    at iterate (/Users/joscha/jimdo/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-watcher/node_modules/gaze/lib/helper.js:52:5)
    at /Users/joscha/jimdo/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-watcher/node_modules/gaze/lib/helper.js:61:11
    at /Users/joscha/jimdo/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-watcher/node_modules/gaze/lib/gaze.js:420:5
    at iterate (/Users/joscha/jimdo/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-watcher/node_modules/gaze/lib/helper.js:52:5)

I looked into the issue and it seems as if it should be resolved with node 0.11, however it still seems to persist:

Running node v0.11.12
[gulp] Using gulpfile ~/jimdo/gulpfile.js
[gulp] Starting 'watch'...
(node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit.
Trace
    at StatWatcher.EventEmitter.addListener (events.js:176:15)
    at Object.fs.watchFile (fs.js:1142:8)
    at Gaze._pollFile (/Users/joscha/jimdo/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-watcher/node_modules/gaze/lib/gaze.js:329:10)
    at /Users/joscha/jimdo/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-watcher/node_modules/gaze/lib/gaze.js:411:12
    at Array.forEach (native)
    at /Users/joscha/jimdo/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-watcher/node_modules/gaze/lib/gaze.js:409:11
    at iterate (/Users/joscha/jimdo/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-watcher/node_modules/gaze/lib/helper.js:52:5)
    at /Users/joscha/jimdo/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-watcher/node_modules/gaze/lib/helper.js:61:11
    at /Users/joscha/jimdo/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-watcher/node_modules/gaze/lib/gaze.js:420:5
    at iterate (/Users/joscha/jimdo/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-watcher/node_modules/gaze/lib/helper.js:52:5)

My next approach was to try and increase the event emitter size in the target project (Gaze), however it seems as if gulp uses a slightly older version (0.5.1) than the current.

I believe setting the maximum event listeners could be done here (https://github.com/shama/gaze/blob/dad5345a2876346fe49a68ee6e4db34205680798/lib/gaze.js), but that would make me need to not only fork gulp, but the whole chain (gulpjs -> vinyl-fs -> glob-watcher -> gaze) which does not seem to be maintainable. Any other ideas on this?

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:13 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
shamacommented, Apr 25, 2014

You can pass options down to gaze with the optional second argument:

gulp.watch(files, { maxListeners: 999 }, ['minJsFiles'])

gaze@0.5.x just has an issue when setting maxListeners: 0, it should set them to infinite but currently it ignores the option (but fixed on 0.6.x).

0reactions
MoOxcommented, Jun 2, 2014

Good to know, thanks for the update !

Read more comments on GitHub >

github_iconTop Results From Across the Web

possible EventEmitter memory leak detected - node.js
I'd like to point out here that that warning is there for a reason and there's a good chance the right fix is...
Read more >
Node.js sends warnings when you add too many listeners to ...
Node.js gives friendly warnings in case you add too much event listeners to an event emitter.
Read more >
Summary for Policymakers — Global Warming of 1.5 ºC - IPCC
A.3.2. Future climate-related risks depend on the rate, peak and duration of warming. In the aggregate, they are larger if global warming exceeds...
Read more >
What's New In Python 3.6 — Python 3.11.1 documentation
New run_coroutine_threadsafe() function to submit coroutines to event loops ... repeated 995 more times] RecursionError: maximum recursion depth exceeded.
Read more >
MIL-STD-750D, Test Methods for Semiconductor Devices
Thermal resistance (emitter to base forward voltage, emitter-only switching ... When the junction temperature exceeds the device maximum rated junction ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found