Repository navigation
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.
Fixes #911.
Removing the final event listener only stopped the decoder's next iteration, leaving an idle connection blocked in Decode. Close the underlying socket to interrupt that read, and close the connection before draining the response body. Guard decoder errors with the monitor lock and session identity so shutdown cannot send to a closed error channel.
Keep each monitor and its retries attached to their original channels. If a connection finishes opening after its listener was removed, close it instead of installing its closer into a new session. Session-scoped shutdown prevents an old monitor from disabling a newly added listener.
The httptest regressions cover idle HTTP and TLS streams across listener re-addition, plus a delayed handshake that completes after a new session is active. All three cases fail against unchanged main and pass with this change. Event delivery behavior is otherwise unchanged.
Validation:
go test -raceon Go 1.27.go test -race -vet all ./...on Go 1.26.0 and Go 1.27.0.Thanks to @shabicheng for the original report, @fsouza for #928, and @yyuuttaaoo for explaining the blocked decoder, body-close ordering, and shutdown-channel hazards in #911 and #930. This implementation uses the existing transport and does not copy #930's transport rewrite.
Implementation and regression tests were produced with OpenAI Codex.