Skip to content

Fix repeated cookie requests for the same key - #14245

Open
atii3343 wants to merge 1 commit into
PaperMC:mainfrom
atii3343:fix/cookie-duplicate-requests
Open

atii3343 wants to merge 1 commit into
PaperMC:mainfrom
atii3343:fix/cookie-duplicate-requests

Conversation

@atii3343

Copy link
Copy Markdown

Bug

Calling retrieveCookie() for the same key multiple times before the client responds caused the pending request to be overwritten. Because the map only stored one request per key, the first future never completed, and the player was kicked with unexpected query response.

Changed

Each cookie key now stores a queue of pending requests, so responses are matched in the same order as the requests were sent. This approach was suggested by electronicboy on the issue.

Adding and removing requests from the queue are done as a single map operation. The future is also removed from the queue before being completed, so requesting the same cookie again from a callback works correctly.

Testing

Added ReadablePlayerCookieConnectionImplTest with 4 test cases. The tests for requesting the same key twice and requesting it again from a callback fail on the old code and pass with this fix.

I also tested it manually on a 26.2 client with a test command that requests the same cookie 3 times. Before the fix, only the last request completed and the player got kicked. After the fix, all 3 requests completed and the player stayed connected.

Fixes #14211

I used Claude to help write the fix and tests, and I reviewed and tested the changes myself.

Requesting the same cookie more than once before the client answered
replaced the earlier pending request, so its future never completed and
the extra response kicked the player. Pending requests are now queued
per key and completed in the order they were sent.

Fixes PaperMC#14211
@atii3343
atii3343 requested a review from a team as a code owner September 11, 2026 11:03
@github-project-automation github-project-automation Bot moved this to Awaiting review in Paper PR Queue Sep 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Awaiting review

Development

Successfully merging this pull request may close these issues.

invoking retrieveCookie(NamespacedKey) with the same namespace twice deletes the first retrive from the map, resulting in kicks

1 participant