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

If the server is not running and client has reconnect data, main menu loads forever #608

Open
Jack-Papel opened this issue Apr 14, 2024 · 3 comments
Assignees
Labels
Bug Something isn't working High Priority First issues to be resolved
Milestone

Comments

@Jack-Papel
Copy link
Collaborator

Jack-Papel commented Apr 14, 2024

GAME_MANAGER.sendRejoinPacket needs to handle websocket failure to connect. Right now it only returns a promise regarding the server response. If the server never connects, it awaits forever.

@Jack-Papel Jack-Papel added Bug Something isn't working High Priority First issues to be resolved labels Apr 14, 2024
@Jack-Papel Jack-Papel added this to the [A] Better UI milestone Apr 14, 2024
@Jack-Papel Jack-Papel self-assigned this Apr 14, 2024
@jpdagostino
Copy link
Member

Promise.race() is what you are looking for.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/race

Maybe wait 10 seconds and if the server never responds, display an error or reload the page.

@jpdagostino
Copy link
Member

return Promise.race([promise, new Promise((resolve, reject) => {
    setTimeout(reject, 10000); // reject after 10s
})]);

instead of

return promise;

@Jack-Papel
Copy link
Collaborator Author

Jack-Papel commented Jun 16, 2024

This is good to know. We'll consider this. I was planning on rejecting the promise after receiving a websocket connection failure instead, but this might be more resilient if any other issues arise

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working High Priority First issues to be resolved
Projects
None yet
Development

No branches or pull requests

2 participants