Fix race condition in team duel match ending causing players to get stuck in duel state#236
Fix race condition in team duel match ending causing players to get stuck in duel state#236
Conversation
Co-authored-by: dumbo-the-developer <83227054+dumbo-the-developer@users.noreply.github.com>
Co-authored-by: dumbo-the-developer <83227054+dumbo-the-developer@users.noreply.github.com>
dumbo-the-developer
left a comment
There was a problem hiding this comment.
it will not fix the issue and it will cause more issues because if match is set completed then ending wont be handled and it will be skipped entirely. so this fixes nothing
|
@copilot it will not fix the issue and it will cause more issues because if match is set completed then ending wont be handled and it will be skipped entirely. so this fixes nothing |
Co-authored-by: dumbo-the-developer <83227054+dumbo-the-developer@users.noreply.github.com>
You're absolutely right. I've fixed this in commit 1b79636. The |
|
@copilot you fixed nothing you called match.setfinished before handlematchend and then you made handlematch end not run if match is finished. it doesnt make any sence as handlematchend wont execute |
I believe there may be a misunderstanding. In the current code (commit 1b79636), the flow is: PlayerDeathEvent handler (line 1049): handleTeamMatchEnd(teamMatch, arena, deadLocation, winningTeam); // NO setFinished() before thisInside handleTeamMatchEnd (lines 220-225): if (match.isFinished()) {
return; // Only blocks if ALREADY finished
}
match.setFinished(); // Mark finished AFTER the check passes
// ... rest of method executes normally with all cleanup logicThe first call executes completely. Subsequent concurrent calls are blocked. Could you clarify what specific issue you're seeing with this approach? |
Team duels (2v2+) sometimes fail to properly end, leaving players stuck in "in duel" state where they cannot use commands or join new matches. The root cause is a race condition where multiple players can die before the match ending cleanup completes, triggering duplicate match ending attempts.
Changes
Core Fix
handleMatchEnd()andhandleTeamMatchEnd()after the early-return checkSafety Guards
handleMatchEnd()andhandleTeamMatchEnd()to prevent processing if match is already finishedTechnical Details
The fix is implemented inside the match ending handler methods:
How it works:
This ensures matches end exactly once with proper cleanup while preventing the race condition where rapid successive deaths could trigger duplicate match ending attempts before the scheduled
arena.endMatch()executes.Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.