PaperMC / PaperMC/Velocity

Fast server switch causes "race condition" in client

Open
#1,334 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

out of scope
Dominant language
Java
Stars
2.3k
Forks
960
Avg merge
5d 10h
Merged PRs (30d)
2

Description

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)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the server-switch/join packet handling and the chat-signing player-session packet path described in the issue. Reproduce rapid switches with a slow or unstable connection; done means the session packet is not sent during the config phase and the client does not disconnect.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.