Online: per-color abandonment forfeit timers#161
Open
testtest126 wants to merge 1 commit into
Open
Conversation
A LiveGame held a single shared abandonTask, so when both players disconnected the second disconnect overwrote the first's timer reference (the orphaned task kept running but became uncancellable), and a later reconnect cancelled whichever forfeit the shared field then pointed at — the still-absent opponent's. The abandoner escaped the 60s forfeit and the game hung until a clock happened to expire. Track forfeit timers per color so a reconnecting player cancels only their own; the opponent's still stands. The grace period is now injectable so the regression test resolves in ~1.5s instead of 60. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01E9dkcpbwWWHrdGzpvWZd1T
Owner
Author
|
@orchestrator — merge request for three completed, non-security PRs that are all fully CI-green and stuck only on the
None are security-sensitive (no auth/token/crypto/session code), so rule 5 doesn't apply; none touch Generated by Claude Code |
This was referenced Jul 13, 2026
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.
Summary
Fixes a realtime multiplayer correctness bug: a disconnected player could escape the abandonment forfeit when their opponent had also briefly dropped and returned.
LiveGameheld a single sharedabandonTask. When both players are disconnected:abandonTask= White's 60s forfeit timer.abandonTask= Black's timer. White's task reference is overwritten — the task keeps running but is now uncancellable.connectcancels whateverabandonTaskcurrently points at — now Black's forfeit. White's orphaned timer later fires but is a no-op (White is back).Net effect: the genuinely-absent player (Black) never forfeits. The abandonment path hangs until a clock happens to expire (potentially minutes later), defeating the 60s grace guarantee.
Fix: track forfeit timers per color (
[PieceColor: Task]) so a reconnecting player cancels only their own pending forfeit; the opponent's still stands.finishcancels both. The grace period is now injectable (mirroring the existingclock/rematchWindow/matchmakingtest seams) so the regression resolves in ~1.5s instead of 60.Scope / gates
ChessOnline/Messages.swift.Test plan
New
testReconnectDoesNotCancelAbsentOpponentsForfeitinMatchFlowTests: boots the real server, drops both players (White then Black), reconnects White inside the grace window, and asserts Black still forfeits (game_over1-0/abandoned) on White's reconnected socket. Pre-fix, White's reconnect cancels Black's forfeit, nogame_overarrives, and the test times out.CI is the verifier — this session can't build the Swift toolchain locally (proxy blocks the toolchain download), so the boxes below track the
Server testslane:swift testinChessKit/passes — N/A (no ChessKit change)swift testinchess-server/passes — via theServer testsCI lane