fix(transport): prevent file log duplication from overlapping batch f…#87
Merged
Merged
Conversation
…lushes FileTransport.addToBatch() fires flush() un-awaited on every Nth entry, so a synchronous burst of writes (e.g. a buffered-log flush replaying many entries) triggers many overlapping flushes. Each flush snapshotted [...this.batch] and only cleared the batch AFTER its async write resolved, so concurrent flushes re-snapshotted the same not-yet-cleared entries and wrote them again — turning N log calls into N-squared file lines. The console transport was unaffected because it writes synchronously with no batch window. Serialize flushes through a single shared drain promise and detach the batch synchronously before awaiting, so entries are written exactly once. Also cancel any pending interval timer when a threshold flush starts. Adds regression tests covering a 500-entry un-awaited burst and concurrent flush() calls.
size-limit report 📦
|
|
🎉 This issue has been resolved in version 1.10.2. |
This file contains hidden or 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
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.
…lushes
FileTransport.addToBatch() fires flush() un-awaited on every Nth entry, so a synchronous burst of writes (e.g. a buffered-log flush replaying many entries) triggers many overlapping flushes. Each flush snapshotted [...this.batch] and only cleared the batch AFTER its async write resolved, so concurrent flushes re-snapshotted the same not-yet-cleared entries and wrote them again — turning N log calls into N-squared file lines. The console transport was unaffected because it writes synchronously with no batch window.
Serialize flushes through a single shared drain promise and detach the batch synchronously before awaiting, so entries are written exactly once. Also cancel any pending interval timer when a threshold flush starts.
Adds regression tests covering a 500-entry un-awaited burst and concurrent flush() calls.
Pull Request
📋 Description
What does this PR do?
Why is this change needed?
Related Issues
🔄 Type of Change
🧪 Testing
Test Coverage
Test Details
Manual Testing
📖 Documentation
🔍 Code Quality
📦 Dependencies
🚀 Performance
🔒 Security
📱 Compatibility
🎃 Hacktoberfest
📸 Screenshots/Examples
Before
After
Code Example
🔗 Additional Context
Deployment Notes
Rollback Plan
Future Considerations
✅ Reviewer Checklist
📝 Notes for Reviewers
🙏 Acknowledgments
Thank you for contributing to Logixia! 🚀