Skip to content

fix: reset readErrCount on success and lower panic threshold to 2#1022

Open
ArminEbrahimpour wants to merge 1 commit into
gorilla:mainfrom
ArminEbrahimpour:fix/next-reader-err-count-reset
Open

fix: reset readErrCount on success and lower panic threshold to 2#1022
ArminEbrahimpour wants to merge 1 commit into
gorilla:mainfrom
ArminEbrahimpour:fix/next-reader-err-count-reset

Conversation

@ArminEbrahimpour

Copy link
Copy Markdown

Problem

readErrCount is incremented on each failed call to NextReader but is
never reset when a subsequent read succeeds. Over a long-lived
connection this can cause an unexpected panic unrelated to any current
error loop.

The threshold of 1000 also has no clear justification — large enough
to miss bugs in testing but small enough to cause surprise panics in
production after hours of normal use.

Changes

  • Reset readErrCount to 0 on successful read
  • Lower panic threshold from 1000 to 2, sufficient for pair-read
    patterns while still catching tight loops
  • Include underlying error in panic message to aid debugging
  • Add tests for both behaviors

readErrCount was never reset on a successful read, meaning it could
accumulate over a long-lived connection and trigger an unexpected panic.

Lowered threshold from 1000 to 2, which is sufficient to support
applications that check errors on every second read while still
catching tight loop bugs. Panic message now includes the underlying
error to aid debugging.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant