Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make node show stack trace after EventEmitter warning

Tags:

node.js

I have this error:

(node:11164) Warning: Possible EventEmitter memory leak detected. 11 end listeners added. Use emitter.setMaxListeners() to increase limit

No stack trace is given so I have no idea which event might be the culprit.

I tried to work around it by overriding console.warn but the stack trace at that point is of no use since console.warn is not called when the listener is added but some arbitrary time afterwards.

like image 215
sparebytes Avatar asked Jul 20 '16 13:07

sparebytes


1 Answers

This changed with Node v6 (or possibly with v5).

Previously, a stack trace was shown automatically, now you have to generate one yourself:

process.on('warning', e => console.warn(e.stack));

Documented here.

like image 182
robertklep Avatar answered Oct 20 '22 04:10

robertklep