question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Race condition with `onAuth()` rejection

See original GitHub issue

If the Colyseus server’s room throws a custom application error or returns false from onAuth(), the Colyseus Unity client sometimes hangs and gets no response.

eg. The below Unity client snippet sometimes never prints either of "Joined room successfully" or "Error joining room".

Client colyseusClient = new Client(COLYSEUS_URL);
Room<GameState> newColyseusRoom;
try {
  Debug.Log("Joining room...");
  newColyseusRoom = await colyseusClient.JoinOrCreate<GameState>("GameRoom", options);
  Debug.Log("Joined room successfully");
} catch (Exception e) {
  Debug.Log("Error joining room");
}

With the server snippet:

export default class GameRoom extends Room<GameState> {
  onAuth(_client: Client, _options: any): Promise<boolean> {
    return false;
  }
}

Colyseus Unity client version: 0.13.2
Colyseus Unity server version: 0.13.7

Possibly related:

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:13 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
rnd256commented, Oct 11, 2020

@endel I’ve verified that the current master branch resolves this issue: https://github.com/rnd256/minimal-colyseus/tree/onauth-rejection-race-condition-2020-10-11-master-branch

(I can’t comment about performance though, which is something you were worried about before)

1reaction
rnd256commented, Sep 3, 2020

FYI I didn’t mean to indicate that I thought one of #118 and #119 was better than the other. #119 just happened to be the one I tested.

@endel unfortunately I’m not well-equipped to measure latency either (my game is not particularly latency-sensitive). Or were you just asking that I verify that the alpha branch fixes this bug?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Race Condition - HackTricks
The problem appears when you accept it and automatically sends an authorization_code to the malicious application. Then, this application abuses ...
Read more >
Race condition when refreshing access tokens in a web ...
One thing I would have expected is that the OIDC Provider rejects the refresh token used for the second refresh process - whichever...
Read more >
Race Conditions in OAuth 2 API implementations | ...
Most of OAuth 2 API implementations seem to have multiple Race Condition vulnerabilities for processing requests for Access Token or Refresh Token.
Read more >
How to solve race condition for refresh api token during ...
The problem is that if there are 5 async calls to refresh token endpoint, then we end with desynced, invalid token in our...
Read more >
Best practice/solution to handle OAUTH access token ...
Multiple calls to refresh the token will result in a failure because the first request will invalidate the others aka 'race condition'.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found