Velocity icon indicating copy to clipboard operation
Velocity copied to clipboard

Fast server switch causes "race condition" in client

Open valaphee opened this issue 1 month ago • 3 comments

Due to chat signing, after a server switch / join packet the client spins up a future which fetches the player session and sends it to the server.

Sometimes server do multiple switches closely together (but still after the first one in Velocities view is finished), and if the player has a slower/unstable connection, the player session packet is sent during the config phase which causes an exception and results in a disconnect.

Contents of the log image

Culprit in the client

if (this.connection.isEncrypted()) {
    this.client.getProfileKeys().fetchKeyPair().thenAcceptAsync(keyPair -> keyPair.ifPresent(this::updateKeyPair), (Executor)((Object)this.client));
}

To circumvent this it might be necessary to wait for the packet to arrive with a timeout (3 seconds should be enough)

valaphee avatar May 27 '24 15:05 valaphee