-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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
Piping a simple program to stdout gives "MaxListenersExceededWarning: Possible EventEmitter memory leak detected when" #16767
Comments
You mean |
Fwiw, I couldn’t reproduce this with master or with v8.9.0… but yes, |
I'm also not able to reproduce this on Linux. |
I think it's this block: https://github.com/nodejs/node/blob/master/lib/console.js#L81-L87. |
I can reproduce it on Mac OS X, you just need to wait some seconds before hitting |
My fix is working, I'll send a PR soon. |
@mscdex I'm also on linux and can reproduce. |
If the console destination is a unix pipe (net.Socket), write() is async. If the destination is broken, we are adding an 'error' event listener to avoid a process crash. This PR makes sure that we are adding that listener only once. Fixes: nodejs#16767
Thanks for the quick turnaround everyone :) |
If the console destination is a unix pipe (net.Socket), write() is async. If the destination is broken, we are adding an 'error' event listener to avoid a process crash. This PR makes sure that we are adding that listener only once. Fixes: #16767 PR-URL: #16770 Fixes: #16767 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Anatoli Papirovski <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Sam Roberts <[email protected]>
If the console destination is a unix pipe (net.Socket), write() is async. If the destination is broken, we are adding an 'error' event listener to avoid a process crash. This PR makes sure that we are adding that listener only once. Fixes: #16767 PR-URL: #16770 Fixes: #16767 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Anatoli Papirovski <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Sam Roberts <[email protected]>
When running a program that produces a lot of output that is consumed by another program in the pipeline, Node gives memory leak errors.
To reproduce try saving this simple program:
Then run
And quit less (type
q
). This results in the following warning being printed out:@mcollina mentioned it is most likely a bug here, https://github.com/nodejs/node/blob/master/lib/console.js#L91-L119
(In general it would be useful as well if the memory leak errors printed out a stack trace so it was easier to hunt down the causes)
/cc @mcollina @addaleax
The text was updated successfully, but these errors were encountered: