Repository navigation
Conversation
writeFrame refused every opcode once closeSentErr was set, so a ping arriving during waitCloseHandshake failed its pong write and aborted the drain before the peer close frame was read. Allow opPong through so RFC 6455 section 5.5.2 is honored and the handshake completes. Fixes coder#585
This branch has not been deployed
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 #585
Once a close frame is sent,
writeFramerefused every opcode, including pong. A ping arriving duringwaitCloseHandshaketherefore failed its pong write, and the error aborted the drain before the peer close frame was read.Closethen mapped the error to nil, so the caller saw success while no pong was sent and the peer close was never consumed.This allows only
opPongthrough after close is sent. RFC 6455 section 5.5.2 requires answering a ping unless a close frame was already received, and here close was sent, not received. Data frames and a second close frame are still refused, and writes after the connection is fully closed are still refused by the closed check below.The regression test uses a raw peer over
net.Pipe: it reads our close frame, sends a ping, expects a pong with the same payload, then sends its close frame. It fails before this change (no pong on the wire) and passes after.What this does not do: it does not change the handling of pings that arrive after the peer close frame was received, and it does not touch the WASM implementation, which cannot control framing.
Tests run (Go 1.27.4):
go test -run TestClosePingAfterCloseSentfails before the fix (unexpected got pong: expected true but got false) and passes after, including-count=10and-race.go test ./...passes.go vet ./...passes, andGOOS=js GOARCH=wasm go build ./...andgo vetpass.Not run locally: the Autobahn suite and the browser WASM tests. CI is the arbiter for those.