A race condition in requests to join a game can cause too many players to join the game because the game doesn't appear full at the time the multiple requests to join are processed. We should fix this by utilizing the new lock-game helper in the subscribe game endpoint.
Detailed Description
783 introduced the lock-game and unlock-game helpers which the backend can use to force requests dealing with a particular game are processed in sequence, rather than in parallel. #783 applies these helpers to the ready.js api endpoint in order to prevent race conditions in requests to ready/unready for a game. We should apply the same locking/unlocking the game techniques in api/controllers/game/subscribe.js to prevent a similar race condition in the subscribe action.
Current Behavior
Multiple players joining a game simultaneously sometimes causes all of them to 'successfully' join, resulting in more than 2 players in the game.
Expected Behavior
Only two players should be able to join a game at a time.
Steps to Reproduce
Sign in with three accounts in three windows
Create a game
Join it as one player
Hit the join button with the two other players at the same time. They might both be admitted into the game, resulting in 3 total players in the game, instead of 2.
Bug Summary
A race condition in requests to join a game can cause too many players to join the game because the game doesn't appear full at the time the multiple requests to join are processed. We should fix this by utilizing the new
lock-game
helper in the subscribe game endpoint.Detailed Description
783 introduced the
lock-game
andunlock-game
helpers which the backend can use to force requests dealing with a particular game are processed in sequence, rather than in parallel. #783 applies these helpers to theready.js
api endpoint in order to prevent race conditions in requests to ready/unready for a game. We should apply the same locking/unlocking the game techniques inapi/controllers/game/subscribe.js
to prevent a similar race condition in the subscribe action.Current Behavior
Multiple players joining a game simultaneously sometimes causes all of them to 'successfully' join, resulting in more than 2 players in the game.
Expected Behavior
Only two players should be able to join a game at a time.
Steps to Reproduce