Repository navigation
fix(dnsserver): abort dropped DoH responses after cancellation - #431
Merged
TMHSDigital merged 1 commit intoNov 17, 2026
Merged
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.
Description
A dropped DoH request now aborts without sending HTTP headers after its server context ends. Returning normally allowed
net/httpto send an implicit empty 200 if the server observed cancellation before the client. The handler useshttp.ErrAbortHandler, which aborts the response without logging a panic stack.The existing dropped-query test waits until the query reaches the handler, checks that it stays unanswered, and then explicitly cancels the client. Its 10-second timeout is a failure bound instead of the former 200 ms delivery deadline. A separate test cancels only the server context while keeping the client live, reproducing the empty-200 failure deterministically.
Related Issue
Fixes #392.
Type of Change
Checklist
Ethical Considerations
Additional Information
Validated on macOS arm64 with Go 1.26.11 and golangci-lint 2.15.0:
TestDoHHandlerCanceledServerContextfails withdropped request answered with status 200 after server cancellation; afterward it gets EOF without an HTTP response.go test -count=1000 -run TestDoHHandler ./internal/dnsserver/passes, including both client cancellation and server cancellation coverage (29.132s).go test -race -shuffle=on ./...passes all 22 packages with tests; it ran concurrently with the repeated DoH test.make lintreports 0 issues;make build, gofmt, andgit diff --checkpass, using the installed Command Line Tools make.Tests use local DNS/HTTPS fixtures only. Prepared with OpenAI Codex assistance.