Repository navigation
fix(execd): send WSCloseTakenOver close frame on takeover during initial writes (#2377) - #2378
Merged
Pangjiping merged 1 commit intoOct 25, 2026
Conversation
markankamaransheogarat-sys
requested review from
Pangjiping,
hittyt and
ninan-nn
as code owners
October 24, 2026 13:59
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8988c18508
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
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.
Closes #2377
Problem
In PR #2376,
evictClosewas introduced usingconn.WriteControl(websocket.CloseMessage, ...)to safely send aWSCloseTakenOver(4001) close frame without deadlocking onconnMu. However, the initial eviction hook registered before the initial replay and connected frame writes still executed a bareconn.Close()without sending a close frame.Consequently, if a concurrent
?takeover=1arrived while the holder was sending its initial replay frame or connected frame, the evicted client received an abnormal closure (1006) instead of 4001 (WSCloseTakenOver), preventing clients from distinguishing deliberate takeovers from unexpected network disconnects.Solution
PTYSessionWebSocketto callevictClose(model.WSCloseTakenOver, model.WSErrCodeTakenOver)beforecancelOnce(), matching the post-initial hook. SinceWriteControlis concurrent-safe with unlocked websocket writes, this cleanly transmits the close frame without racing.TestPTYWS_TakeoverDuringInitialReplayClosesHolderWithCloseCodeinpty_ws_test.go, verifying that evicting a holder while its initial replay write is blocked transmits the 4001 close frame.Verification
go test -v -run "^TestPTYWS_Takeover" ./pkg/web/controller(all 5 takeover tests passed).pkg/web/controllertest suite under Linux: all tests PASS.