From eea631f69e496c2c3179fef023a642de06c37d29 Mon Sep 17 00:00:00 2001 From: Anon Date: Mon, 27 Jul 2026 00:35:18 +0200 Subject: [PATCH] fix: preserve queued disconnect reason --- MinecraftClient/Protocol/Handlers/Protocol18.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/MinecraftClient/Protocol/Handlers/Protocol18.cs b/MinecraftClient/Protocol/Handlers/Protocol18.cs index 968e6465..86ad7364 100644 --- a/MinecraftClient/Protocol/Handlers/Protocol18.cs +++ b/MinecraftClient/Protocol/Handlers/Protocol18.cs @@ -304,7 +304,10 @@ namespace MinecraftClient.Protocol.Handlers { Stopwatch stopWatch = Stopwatch.StartNew(); long nextUpdateDue = 0; - while (!packetQueue.IsAddingCompleted) + // Continue until the reader has finished and every queued packet has been handled. + // A server can close immediately after a Disconnect packet, completing the queue + // while that final packet is still waiting to be processed. + while (!packetQueue.IsCompleted) { cancelToken.ThrowIfCancellationRequested();