- 
                Notifications
    You must be signed in to change notification settings 
- Fork 1.8k
Fix/http transport memory leak #2565
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
base: master
Are you sure you want to change the base?
Fix/http transport memory leak #2565
Conversation
- Remove unnecessary setImmediate wrapper in Console transport log method - Add stress tests to verify memory usage and event listener cleanup - Fix issue winstonjs#2548
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few questions and comments here
| log(info, callback) { | ||
| // Handle callback immediately since HTTP requests are already async | ||
| if (callback) { | ||
| return callback(); | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would we return here if there's a call back? We would then exit the function before anything is logged?
| _doBatch(options, callback, auth, path) { | ||
| // Handle callback immediately since batching is async | ||
| if (callback) { | ||
| return callback(); | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same q here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert changes to this file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please delete this file from this PR as it's part of your other PR #2564
| // First message stored, start the timeout | ||
| this.batchTimeoutID = setTimeout(() => { | ||
| this.batchTimeoutID = -1; | ||
| this._doBatchRequest(null, auth, path); | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is null passed rather than callback?
| // max batch count reached, send immediately | ||
| clearTimeout(this.batchTimeoutID); | ||
| this.batchTimeoutID = -1; | ||
| this._doBatchRequest(null, auth, path); | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same q here
Fix Memory Leaks in Console and HTTP Transports
Description
This PR fixes memory leak issues in both the Console and HTTP transports that occur when logging a large number of messages in quick succession. The issues were reported in #2548 and #2465, affecting Winston 3.x.x versions.
Problems
Console Transport:
setImmediateto emit the 'logged' event created many pending operationsHTTP Transport:
Solutions
Console Transport:
setImmediatewrapper since console writes are already asyncHTTP Transport:
Changes
setImmediatewrapper in Console transport's log methodTesting
Added new stress tests that:
To run the tests:
Related Issues
Backwards Compatibility
These changes maintain full backwards compatibility as they only optimize internal operations without changing the transports' APIs or behaviors.