Skip to content

Commit 82f3879

Browse files
authored
Fix logging a TaskCanceledException out of users control (#2030)
1 parent 1917961 commit 82f3879

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/Discord.Net.WebSocket/ConnectionManager.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,14 @@ public virtual async Task StartAsync()
7878
nextReconnectDelay = 1000; //Reset delay
7979
await _connectionPromise.Task.ConfigureAwait(false);
8080
}
81+
catch (OperationCanceledException ex)
82+
{
83+
// 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.
84+
// ref #2026
85+
86+
Cancel(); //In case this exception didn't come from another Error call
87+
await DisconnectAsync(ex, !reconnectCancelToken.IsCancellationRequested).ConfigureAwait(false);
88+
}
8189
catch (Exception ex)
8290
{
8391
Error(ex); //In case this exception didn't come from another Error call

0 commit comments

Comments
 (0)