-
Notifications
You must be signed in to change notification settings - Fork 861
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
Warning: possible EventEmitter memory leak detected #144
Comments
How are you creating these loggers? The best approach is to create a main one, and then create as many child as you need to. |
True, that's the approach I'm using in my code. You made me realize only the tests would create multiple "main loggers". So I will just use Thanks, closing |
are you using extreme mode? Or a specific transform on top of
process.stdout?
Il giorno gio 8 dic 2016 alle 18:52 Stéphane Bruckert <
notifications@github.com> ha scritto:
… Closed #144 <#144>.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#144 (comment)>, or mute the
thread
<https://github.com/notifications/unsubscribe-auth/AADL49wbCxQXDMqbI2DjAAI7ve12wj8Xks5rGEPPgaJpZM4LIEzD>
.
|
I would like to resurrect this issue and provide more context: This happens in my tests, too, even though I have only a single pino instance in my application. To successfully replicate the warning:
Seems like the log data is piped through a pretty-printer stream and then sent to I could call Please note that these are memory leaks; long-running For completeness, below you can find the stack trace, I think it's almost the same as the original one.
|
You should not use prettyPrint in tests, or print logs in there for that matter. Logs are for production code, not test code (unless you are testing logging, but then you will send logs somewhere else). A completely different solution is to rework how prettyPrint works in a way that avoids pipe or pump. If you want to send a PR, feel free to do that! |
@mcollina The test suite is for a big backend server which logs request info and other stuff. Frequently that log info is important to find a bug or other undesired behaviour. Not having the logs next to the test suite's progress info the log data is almost useless as there would be no correlation between the log data and the test which generated the log message. I guess it's fine not to use |
I think something like this should work or your usecase (pseudocode): var pino = require('pino')
// test starts..
var pretty = pino.pretty()
pretty.pipe(process.stdout)
var log = pino(pretty)
// test ends
pretty.unpipe(process.stdout) |
Thanks, I'll try the idea of manually hooking up the pretty printer. Thanks! 👍 |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Hi,
In my tests, I'm creating more than 10 loggers, which leads to the warnings below.
I could easily hide them by setting
process.stdout.setMaxListeners(Infinity)
at the top of the file, but that would be only a workaround I believe.What's your opinion on this guys as I might not want to
setMaxListeners
in production? Is this something Pino should handle or should we handle it ourselves? Any way toclose
a stream?Thanks
The text was updated successfully, but these errors were encountered: