Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MaxListenersExceededWarning when using containers #1620

Closed
1 of 2 tasks
sla89 opened this issue Mar 21, 2019 · 6 comments
Closed
1 of 2 tasks

MaxListenersExceededWarning when using containers #1620

sla89 opened this issue Mar 21, 2019 · 6 comments

Comments

@sla89
Copy link

sla89 commented Mar 21, 2019

Please tell us about your environment:

  • winston version?
  • _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

@DABH
Copy link
Contributor

DABH commented Mar 24, 2019

They are all going to the same transport -- as you can see we hard-coded 30 as the max per transport before throwing warning:
https://github.com/winstonjs/winston/search?q=setmaxlisteners&unscoped_q=setmaxlisteners
You will likely have slightly degraded performance with that many loggers all listening to the same transport. Is there a reason you need that specific design, or could you use several or many transports (e.g. one transport per logger)?

Unless there is a compelling argument, I'd prefer to not boost these limits again, but let me know :)

@DABH DABH closed this as completed Mar 24, 2019
@sla89
Copy link
Author

sla89 commented 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?

@fabiante
Copy link

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?

@ira-gordin-sap
Copy link

@fabiante , I have the same as you. Do you have some new regarding it?
@sla89 , all our loggers should log to the same FileTransport because we want all log messages in the same file as you. Do you have some new regarding it?
@DABH , could you please advise what we supposed to do in our scenario?

@sla89
Copy link
Author

sla89 commented May 3, 2020

@ira-gordin-sap no, I don't. Everything remained the same.

@gauravmahto
Copy link

@DABH I'm facing the same problem as @sla89. The requirement is exactly what @fabiante has mentioned. If you think this shouldn't be done or is a bad design then maybe we can document this and show an example with the best practice. Could you please guide us?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants