baderror: Treat HTTP/2 NO_ERROR as closed#102
Open
LarryWang142 wants to merge 1 commit into
Open
Conversation
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.
baderror: Treat HTTP/2 NO_ERROR as closed
Problem
sing-box logs spurious error/warning messages when HTTP/2 connections are closed gracefully. The log contains noisy entries like:
This is a false positive — the connection closed normally, but the error wrapper misclassifies it.
Root Cause
In
common/baderror/baderror.go, theWrapH2()function converts various HTTP/2 error messages into harmless sentinel errors (e.g.,net.ErrClosed). This prevents normal connection teardown from being logged as errors upstream.HTTP/2 uses a
NO_ERRORcode (0x0) in GOAWAY and RST_STREAM frames to indicate graceful shutdown. When the peer sendsNO_ERROR, Go's HTTP/2 implementation may return an error string containing"; NO_ERROR". This pattern was not in the recognized list, so it was treated as a genuine error.Fix
Added
"; NO_ERROR"to the recognized patterns inWrapH2():This ensures HTTP/2 graceful shutdown (NO_ERROR) is treated the same as other normal close signals — returning
net.ErrClosedinstead of the raw error, which the caller handles silently.Changes
common/baderror/baderror.go: Added"; NO_ERROR"to the close detection listTesting