From 82f3879aaf2e1b4f40ffb327be926a43e2e174a9 Mon Sep 17 00:00:00 2001 From: Quin Lynch <49576606+quinchs@users.noreply.github.com> Date: Sun, 30 Jan 2022 02:55:32 -0400 Subject: [PATCH] Fix logging a TaskCanceledException out of users control (#2030) --- src/Discord.Net.WebSocket/ConnectionManager.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Discord.Net.WebSocket/ConnectionManager.cs b/src/Discord.Net.WebSocket/ConnectionManager.cs index f304d4ea8..ec5eb93eb 100644 --- a/src/Discord.Net.WebSocket/ConnectionManager.cs +++ b/src/Discord.Net.WebSocket/ConnectionManager.cs @@ -78,6 +78,14 @@ namespace Discord nextReconnectDelay = 1000; //Reset delay await _connectionPromise.Task.ConfigureAwait(false); } + catch (OperationCanceledException ex) + { + // Added back for log out / stop to client. The connection promise would cancel and it would be logged as an error, shouldn't be the case. + // ref #2026 + + Cancel(); //In case this exception didn't come from another Error call + await DisconnectAsync(ex, !reconnectCancelToken.IsCancellationRequested).ConfigureAwait(false); + } catch (Exception ex) { Error(ex); //In case this exception didn't come from another Error call