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.

possible EventEmitter memory leak detected with mpromise

See original GitHub issue
var def = Model.find({}).exec()

// if we have more then 11 "then waiters"
def.then(function(){
...
})

if we have more then 11 “then waiters” we have an error in console:

(node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to in
crease limit.
Trace
    at Promise.EventEmitter.addListener (events.js:160:15)
    at Promise.on (...\node_modules\mongoose\node_modules\mprom
ise\lib\promise.js:61:31)
    at Promise.onReject (...\node_modules\mongoose\node_modules
\mpromise\lib\promise.js:154:15)
    at Promise.then (...\node_modules\mongoose\node_modules\mpr
omise\lib\promise.js:216:10)
    at Object.<anonymous> (...\app\models\muller-word.js:227:21
)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)

Not sure if this is expected, but I often use promises in such a way that there may be a lot of listeners for deferred result.

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:13

github_iconTop GitHub Comments

3reactions
mattcaseycommented, Jun 9, 2015

FYI if you have the connection object, you can setMaxListeners() on it…

var connection = mongoose.createConnection(config.MONGO_URI, config.MONGO_OPTIONS);
connection.setMaxListeners(0); // allow infinite listeners
0reactions
vkarpov15commented, Oct 12, 2015

Just use mongoose.Promise = global.Promise; (if you’re using node 4 and mongoose 4.1) and this issue should go away as specified in https://github.com/Automattic/mongoose/issues/1992#issuecomment-134257407

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 >
Possible EventEmitter memory leak detected. #63 - GitHub
My project installed promise-socket@6.0.3, when I call 'socket.writeAll' in setInterval, some warnings printed on console.
Read more >
Understanding memory leaks in node.js part 2 - alxolr
The following example will show an easy way to add a memory leak in your code, ... MaxListenersExceededWarning: Possible EventEmitter memory leak detected....
Read more >
Understanding node.js's possible eventemitter leak error ...
js, you'll frequently see this error message: (node) warning: possible EventEmitter memory leak detected. 11 a listeners added. Use emitter.
Read more >
what is this "Possible EventEmitter memory leak detect ed ...
what is this "Possible EventEmitter memory leak detect ed" and what to do about it? Hi guys, im running a .js file in...
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