Throttle repeated packet-parse error logs in FullPacketParser - #179
Open
u9g wants to merge 1 commit into
Open
Conversation
A malformed or mismatched stream can make the same packet fail to parse on every frame it sends. FullPacketParser logged the full stack each time, so one persistent fault produced thousands of identical stacks a minute and buried every other log line -- a single session was seen writing ~15k identical PartialReadError stacks, tens of megabytes. Each distinct error (keyed on the top of its stack) is now logged in full on its first occurrence, then only at the 1st, 2nd, 4th, 8th, ... with a repeat count, so a persistent fault costs O(log n) lines instead of n. The same throttle covers the chunk-size-mismatch log two lines up. Counts are per parser instance; noErrorLogging still silences everything.
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.
Problem
When a stream is malformed or version-mismatched, the same packet can fail to parse on every frame the server sends.
FullPacketParser._transformlogged the full stack on eachPartialReadError, so one persistent fault produced thousands of identical stacks a minute and drowned every other log line. A real session was seen emitting ~15,000 identicalRead error for undefined : undefinedstacks — tens of megabytes — over ~45 minutes.Change
A small per-instance throttle: each distinct error (keyed on the top line of its stack) is logged in full on its first occurrence, then again only at the 1st, 2nd, 4th, 8th, … occurrence with a repeat count. A persistent fault costs O(log n) lines instead of n, while the first full stack — the part you actually diagnose from — is always kept, and distinct faults are still each reported. The same throttle is applied to the chunk-size-mismatch log two lines up, which is the same failure family.
noErrorLoggingstill suppresses everything, unchanged.Testing
npm test— all 501 existing tests pass; parser semantics unchanged.