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.

MaxListenersExceededWarning when using containers

See original GitHub issue

Please tell us about your environment:

  • winston version?
    • winston@2
    • winston@3.2.1
  • _node -v outputs: v8.15.1 and v10.15.3
  • _Operating System? Linux 16.04 and Windows 10

What is the problem?

Using a container that has a predefined set of transports leads to MaxListenersExceededWarning when adding multiple loggers:

$ node index.js
(node:8512) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 31 unpipe listeners added. Use emitter.setMaxListeners() to increase limit
(node:8512) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 31 error listeners added. Use emitter.setMaxListeners() to increase limit
(node:8512) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 31 drain listeners added. Use emitter.setMaxListeners() to increase limit
(node:8512) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 31 close listeners added. Use emitter.setMaxListeners() to increase limit
(node:8512) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 31 finish listeners added. Use emitter.setMaxListeners() to increase limit

What do you expect to happen instead?

No warning.

Other information

Here is a sample repo. Simply run node index.js: https://github.com/sla89/winston_maxlisteners

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
sla89commented, Mar 26, 2019

We have multiple loggers with different labels so that we can identify which module logged the message. All loggers should log to the same FileTransport because we want all log messages in the same file. Is it safe to have multiple FileTransports that target the same file even when rolling logs are enabled?

1reaction
FabianTecommented, Sep 10, 2019

I am too having the same scenario as @sla89

I create a logger instance for each class I am creating (one per class, not one per class instance) and each logger has a different label.

I though that having a single console and a single file transport should be used with many logger instances using them. Is that wrong?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Gatsby / Docker causes MaxListenersExceededWarning
I am having a really weird issue here. Firstly when I run local build on my pc with Gatsby Build I don't have...
Read more >
Possible EventEmitter memory leak detected" nodejs - Server ...
Use emitter.setMaxListeners() to increase limit (node:1584) MaxListenersExceededWarning: Possible EventEmitter memory leak detected.
Read more >
Possible EventEmitter memory leak detected - Bitbucket
Since a couple of days I see that my poste docker is using 100% CPU load. ... (node:1108) MaxListenersExceededWarning: Possible EventEmitter ...
Read more >
Actions execution throws "MaxListenersExceededWarning"
(node:18) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 error listeners added to [Socket]. Use emitter.
Read more >
Node.js Memory Leak Detection: How to Debug & Avoid Them
Learn what Node.js memory leaks are. Discover common causes and go through the whole debugging process, from detection to fixing and ...
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