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.

Memory leaks - MaxListenersExceededWarning

See original GitHub issue

Please tell us about your environment:

npm view winston version 3.3.3

What is the problem?

Node will release a warning: MaxListenersExceededWarning

(node:89848) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 5 uncaughtException listeners added to [process]. Use emitter.setMaxListeners() to increase limit (Use node --trace-warnings ... to show where the warning was created)

What do you expect to happen instead?

No warning

How to reproduce:

`const winston = require(“winston”); const { transports } = require(“winston”);

// const EventEmitter = require(‘events’); // EventEmitter.defaultMaxListeners = 4;

const createLogger = () => { winston.createLogger({ transports: [ new winston.transports.Console({ handleExceptions: true, }), ], exceptionHandlers: [new transports.File({ filename: “exceptions.log” })], }) }

for (let i = 0; i <= 4; i++) { createLogger(); }`

Removing handleExceptions and exceptionHandlers will work and the warning is not shown

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
wbtcommented, Jan 10, 2022

The first half was included in yesterday’s release, and I’ve recently merged the second to go out in the next release.

1reaction
r4dulcommented, Jan 7, 2022

I think this is fixed by #1824 and/or #1973, though they have not yet been included in a release (hopefully coming soon!)

Also FYI, it’s a warning rather than an error, but the “possible” memory leak referred to is a real one.

Thank you very much for your fast answer.

Read more comments on GitHub >

github_iconTop Results From Across the Web

possible EventEmitter memory leak detected - node.js
I'd like to point out here that that warning is there for a reason and there's a good chance the right fix is...
Read more >
Possible EventEmitter memory leak detected. 11 ... - GitHub
Describe the bug When using simple cache adapters MaxListenersExceededWarning is emitted. This has previously been investigated in #792 and #1128 but either ...
Read more >
Possible EventEmitter memory leak detected. 11 scanStop ...
The node red console indicates "MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 scanStop listeners added. Use emitter.
Read more >
Help me (MaxListeners) - Code Help - Discord - Glitch Support
MaxListenersExceededWarning : Possible EventEmitter memory leak detected. 11 message listeners added. Use emitter.setMaxListeners() to increase limit
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