fix: reveal tossup answer when all remaining players have buzzed#516
Open
xpoes123 wants to merge 1 commit into
Open
fix: reveal tossup answer when all remaining players have buzzed#516xpoes123 wants to merge 1 commit into
xpoes123 wants to merge 1 commit into
Conversation
The previous check compared `buzzes.length` to the socket count, but `this.buzzes` is never pruned when a player leaves the room. So if a player negged and then left, every subsequent neg would push the buzz count above the remaining socket count, preventing the answer from ever being revealed until the question ran out of words. Switch the condition to "every current socket is in buzzes" — this ignores stale userIds from departed players and correctly handles newly joined players who haven't buzzed yet. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
quizbowl/TossupRoom.jsdecides whether to reveal the answer after a neg by checkingthis.buzzes.length === Object.keys(this.sockets).length. Butthis.buzzesis only reset between tossups (endCurrentTossup) —Room.leave()removes the userId fromthis.socketsand never touchesthis.buzzes. So once a player negs and leaves, the buzz array carries a stale entry forever, and the equality check drifts out of sync with the actual room population.Failure scenario
rebuzzoff.buzzes = [A],sockets = {A, B}(1 ≠ 2, reading resumes — correct).buzzes = [A](stale),sockets = {B}.buzzes = [A, B],sockets = {B}(2 ≠ 1, answer is not revealed even though every player still in the room has already buzzed).A symmetric variant (A negs, B leaves without buzzing) makes the answer reveal after a single neg, which is also wrong when
rebuzzis off.Fix
Replace the length comparison with "every current socket has already buzzed":
This ignores ghost entries left behind by departed players and correctly accounts for newly joined players who haven't buzzed yet (they'll be in
socketsbut not inbuzzes, so the answer won't prematurely reveal).Test plan
rebuzzoff: player A buzzes/negs, leaves, player B buzzes/negs → answer is revealed.rebuzzoff: player A buzzes/negs, player B joins mid-tossup → reading continues until B also buzzes or the question ends (no premature reveal).rebuzzoff: solo player negs → answer revealed (unchanged behavior).rebuzzon: behavior unchanged (the whole branch is gated on!this.settings.rebuzz).🤖 Generated with Claude Code