-
Notifications
You must be signed in to change notification settings - Fork 769
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
Avoid creating multiple SIGHUP listeners for File Appender #1110
Merged
lamweili
merged 2 commits into
log4js-node:master
from
lamweili:Fixes-#852-MaxListenersExceededWarning
Jan 5, 2022
Merged
Avoid creating multiple SIGHUP listeners for File Appender #1110
lamweili
merged 2 commits into
log4js-node:master
from
lamweili:Fixes-#852-MaxListenersExceededWarning
Jan 5, 2022
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This issue can be tested with the following codes in NodeJS. const log4js = require('log4js');
log4js.configure({
appenders: {
a1: { type: 'file', filename: 'app1.log' },
a2: { type: 'file', filename: 'app2.log' },
a3: { type: 'file', filename: 'app3.log' },
a4: { type: 'file', filename: 'app4.log' },
a5: { type: 'file', filename: 'app5.log' },
a6: { type: 'file', filename: 'app6.log' },
a7: { type: 'file', filename: 'app7.log' },
a8: { type: 'file', filename: 'app8.log' },
a9: { type: 'file', filename: 'app9.log' },
a10: { type: 'file', filename: 'app10.log' },
a11: { type: 'file', filename: 'app11.log' },
a12: { type: 'file', filename: 'app12.log' }
},
categories: {
default: {
appenders: [ 'a1', 'a2', 'a3', 'a4', 'a5', 'a6', 'a7', 'a8', 'a9', 'a10', 'a11', 'a12' ],
level: 'debug'
}
}
}); > (node:18567) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 SIGHUP listeners added to [process]. Use emitter.setMaxListeners() to increase limit
(Use `node --trace-warnings ...` to show where the warning was created) A check on the listener count: process.listenerCount('SIGHUP'); 12 |
After the patch, no more A check on the listener count: process.listenerCount('SIGHUP'); 1 |
Awesome - thanks for this. Could you add an automated test that covers it, please? |
I think the issue is that each file appender instance adds a SIGHUP handler, when they could all use the same handler. I'll see if I can work on a fix. _Originally posted by @nomiddlename in log4js-node#852 (comment)
lamweili
force-pushed
the
Fixes-#852-MaxListenersExceededWarning
branch
from
December 16, 2021 16:43
d991f3b
to
ac72e99
Compare
Hi @nomiddlename, I added the automated test as requested. |
This was referenced Jan 10, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #556, Fixes #700, Fixes #785, Fixes #852, Fixes #886
Implemented a fix based on @nomiddlename's comment, to create a single SIGHUP listener.