MCCTeam / Minecraft-Console-Client

Lightweight console for Minecraft chat and automated scripts
https://mccteam.github.io
Other
1.67k stars 402 forks source link

fix(Protocol18.cs): OperationCanceledException when /reco or /quit #2656

Closed oldkingOK closed 10 months ago

oldkingOK commented 10 months ago

Tested version:

Occasionally get OperationCanceledException when typing /reco or /quit

> Unhandled exception. System.OperationCanceledException: The operation was canceled.
   at System.Threading.CancellationToken.ThrowOperationCanceledException()
   at System.Collections.Concurrent.BlockingCollection`1.TryAddWithNoTimeValidation(T item, Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at System.Collections.Concurrent.BlockingCollection`1.Add(T item, CancellationToken cancellationToken)
   at MinecraftClient.Protocol.Handlers.Protocol18Handler.PacketReader(Object o)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
Aborted

Add catch OperationCanceledException to MinecraftClient/Protocol/Handlers/Protocol18.cs -> Protocol18Handler -> PacketReader() then the client can normally reconnect and quit

milutinke commented 10 months ago

Thank you for your contribution