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

Infinite loading screen with simultaneous match joins #1100

Open
Neodark7 opened this issue Oct 7, 2022 · 5 comments
Open

Infinite loading screen with simultaneous match joins #1100

Neodark7 opened this issue Oct 7, 2022 · 5 comments
Labels
bug Lobby Related to the Lobby part of the codebase

Comments

@Neodark7
Copy link

Neodark7 commented Oct 7, 2022

Hi ! i have a custom lobby mechanism on my project which implement basic matchmaking between players.
When sufficient players have joined the lobby i create the match from my api and send an event to all the players to redirect them to the match page.
When the match page load, an http call occurs to log the user to the game server.

It seems that the boardgame implementation cannot handle simultaneous connection changes properly.
When someone logs into the match (https://github.com/boardgameio/boardgame.io/blob/main/src/master/master.ts#L400)
the match metadata is fetched from my database, modified to include the new metadata, sent to all clients and then saved to the database.

When 2 players joins the match simultaneously, this logic is called 4 times simultaneously and it looks like that some players are overriding the metadata changes of previous users.

For example:

Player 1 is redirected to match page
Player 2 is redirected to match page

Player 1 onConnectionChange method start and fetch metadata
Player 2 onConnectionChange method start and fetch metadata

Player 1 onConnectionChange method modify metadata and save it to the database
Player 2 onConnectionChange method modify metadata and save it to the database

as Player 2 fetched the metadata before Player 1 finished modifying and saving it to the database, when Player 2 modify and save the metadata into the database, the data is outdated and does not contain Player 1 isConnected and credentials values. Player 2 is correctly logged into the match but Player 1 stay on the "Connecting..." screen indefinitely and the match get stuck when his turn start...

Sometimes everything plays nicely in the correct order but most of the time, for example in a 4 players match, a player stay on the loading screen and the match is blocked, this is really critical for my project, how can this be fixed ?

@vdfdev
Copy link
Contributor

vdfdev commented Oct 8, 2022

Yep, this is a known issue: #429 our lobby lacks transactions and concurrency controls. Any contribution to help with that would be appreciated.

@vdfdev
Copy link
Contributor

vdfdev commented Oct 8, 2022

Basically, you need to serialize the requests in your client to avoid this isue

@vdfdev vdfdev added bug Lobby Related to the Lobby part of the codebase labels Oct 8, 2022
@Neodark7
Copy link
Author

@vdfdev what do you mean by "serializing the requests in your client" ?

@vdfdev
Copy link
Contributor

vdfdev commented Oct 12, 2022

Do them sequentially, not in parallel

@Neodark7
Copy link
Author

@vdfdev I don't see how i can do that since all players joins the game at the same time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Lobby Related to the Lobby part of the codebase
Projects
None yet
Development

No branches or pull requests

2 participants