Winston: EventEmitter memory leak. v.2.0.0

Created on 4 Nov 2015  ·  3Comments  ·  Source: winstonjs/winston

Try v2.0.0. but the same problem arises.
Request you to check.

I use winston v1.0.2. I met with the following error log.
Is there any solution?

my transport

transports: [
  new winston.transports.Console({
    level:debug,
    colorize: 'true'
  }),
  new (winston.transports.DailyRotateFile)({
    datePattern: '.yyyy-MM-dd',
    filename: path.join(__dirname, '../logs/chat.error'),
    handleExceptions: true,
    prettyPrint: true,
    level: error,
    timestamp: 'true'
    //maxsize: 500000000 //byte
  })
]

error log

(node) warning: possible EventEmitter memory leak detected. 11 logged listeners added. Use emitter.setMaxListeners() to increase limit.
Trace
    at addListener (events.js:239:17)
    at once (events.js:265:8)
    at Transport.logException (c:\Users\Coupang\WebstormProjects\livechat-agent\node_modules\winston\lib\winston\transports\transport.js:132:8)
    at logAndWait (c:\Users\Coupang\WebstormProjects\livechat-agent\node_modules\winston\lib\winston\logger.js:646:15)
    at c:\Users\Coupang\WebstormProjects\livechat-agent\node_modules\async\lib\async.js:157:13
    at _each (c:\Users\Coupang\WebstormProjects\livechat-agent\node_modules\async\lib\async.js:57:9)
    at Object.async.each (c:\Users\Coupang\WebstormProjects\livechat-agent\node_modules\async\lib\async.js:156:9)
    at Logger._uncaughtException (c:\Users\Coupang\WebstormProjects\livechat-agent\node_modules\winston\lib\winston\logger.js:669:9)
    at emitOne (events.js:77:13)
    at process.emit (events.js:169:7)

Most helpful comment

Just fyi, I ran into this issue as well. It was dealing with unhandle exception listeners. There is a method you need to call on your logger .exceptions.unhandle() to remove the listeners. This really should be better documented, or if it is, I could not find it easily. I dug through the code to find this call (actually I found a deprecated call that pointed me to this one, though the deprecation log text is spelled wrong).

All 3 comments

Please provide the exact code you are running against [email protected]. It is very suspicious that the above code sample is exactly what you are running since _winston.transports.DailyRotateFile was moved to winston-daily-rotate-file in 2.0.0_

This was a known issue in 1.x branch that we fixed. Please confirm (with full reproducible code sample) that you are using [email protected].

Even if this is still occuring it's really not a big issue. You can just run:

logger.setMaxListeners(0);

and that will definitely fix it.

So I was updating bithavoc/express-winston to work with [email protected] and this issue came up again. I dont know if setting the max to infinity is a good idea to get around this

Just fyi, I ran into this issue as well. It was dealing with unhandle exception listeners. There is a method you need to call on your logger .exceptions.unhandle() to remove the listeners. This really should be better documented, or if it is, I could not find it easily. I dug through the code to find this call (actually I found a deprecated call that pointed me to this one, though the deprecation log text is spelled wrong).

Was this page helpful?
0 / 5 - 0 ratings