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.

Got MaxListenersExceededWarning while using winston.

See original GitHub issue

I got a warning message while using winston@3.0.0-rc5 after calling the createLogger function multiple times in my test cases.

(node:28754) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 end listeners added. Use emitter.setMaxListeners() to increase limit
    at _addListener (events.js:280:19)
    at DerivedLogger.addListener (events.js:297:10)
    at DerivedLogger.Readable.on (_stream_readable.js:772:35)
    at DerivedLogger.once (events.js:341:8)
    at DerivedLogger.Readable.pipe (_stream_readable.js:580:9)
    at DerivedLogger.add (/Users/NS/yk/node_modules/winston/lib/winston/logger.js:299:8)
    at DerivedLogger.<anonymous> (/Users/NS/yk/node_modules/winston/lib/winston/logger.js:82:12)
    at Array.forEach (<anonymous>)
    at DerivedLogger.Logger.configure (/Users/NS/yk/node_modules/winston/lib/winston/logger.js:81:24)
    at DerivedLogger.Logger (/Users/NS/yk/node_modules/winston/lib/winston/logger.js:22:8)
    at new DerivedLogger (/Users/NS/yk/node_modules/winston/lib/winston/create-logger.js:24:44)
    at Object.module.exports [as createLogger] (/Users/NS/yk/node_modules/winston/lib/winston/create-logger.js:58:10)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:23 (12 by maintainers)

github_iconTop GitHub Comments

4reactions
Acionyxcommented, Jun 22, 2018

Problem still exists for DailyRotateFile. Code above is enough to reproduce issue.

3reactions
Acionyxcommented, Jun 22, 2018

Yep. My case: I’m trying to label messages from different modules with winston 3.0, e.g. [DB] Connected ok, [Main] Server started ok. So what i want to do, is simple call on the top of file, like this: const logger = createNamedLogger('Main');, where createNamedLogger is my wrapper to create logger with labeled Console and File transports.

I tried to find easy way to do such trivial thing, but i did not found it in docs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

node.js - Winston - MaxListenersExceededWarning: Possible ...
when one creates a lot of logger instances using transport. ... it got fixed by calling winstonLoggerInstance.clear() when I was done with ......
Read more >
winstonjs/winston - Gitter
Hi, I've recently been getting this warning (node:26105) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 unpipe listeners added ...
Read more >
Possible EventEmitter memory leak detected-node.js
Coding example for the question Winston - MaxListenersExceededWarning: ... it got fixed by calling winstonLoggerInstance.clear() when I was done with the ...
Read more >
EventEmitter Memory Leak Issue : r/node - Reddit
I am running into an issue when developing a node REST api. I am using NextJS and winston for logging. I think the...
Read more >
Understanding memory leaks in node.js part 2 - alxolr
In the second part, we will focus on event emitters and cached objects. ... (node:10031) MaxListenersExceededWarning: Possible EventEmitter memory leak ...
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