Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Three players joining a game simultaneously can cause all three to join #785

Open
itsalaidbacklife opened this issue Nov 18, 2023 · 1 comment
Labels
backend Requires changes to the (node) backend webserver bug Something isn't working

Comments

@itsalaidbacklife
Copy link
Contributor

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 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

  1. Sign in with three accounts in three windows
  2. Create a game
  3. Join it as one player
  4. 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.
@itsalaidbacklife itsalaidbacklife added bug Something isn't working backend Requires changes to the (node) backend webserver labels Nov 18, 2023
@fuveluck
Copy link
Contributor

I`ll take it :)

@Haviles04 Haviles04 assigned fuveluck and unassigned fuveluck Mar 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Requires changes to the (node) backend webserver bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants