From f6e320053bea34a577186f829bf3dcf10c7d04fa Mon Sep 17 00:00:00 2001 From: Christopher Felegy Date: Sat, 18 May 2019 09:42:37 -0400 Subject: [PATCH] fix: ensure that exceptions will be logged Resolves #1238. I'm not sure where this bug came from, a git blame revealed no change to the timed event handler code since it was initiall written two years ago. I've found that when the event handler times out, the handler task will be manually completed (as opposed to within Task.WhenAny), which then bubbles the exception and allows the error to be logged. Ensuring that the handler is completed individually, regardless of whether or not the timeout task completed, seems to fix this problem. --- src/Discord.Net.WebSocket/DiscordSocketClient.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Discord.Net.WebSocket/DiscordSocketClient.cs b/src/Discord.Net.WebSocket/DiscordSocketClient.cs index 7f30230d7c..4deb2f40bf 100644 --- a/src/Discord.Net.WebSocket/DiscordSocketClient.cs +++ b/src/Discord.Net.WebSocket/DiscordSocketClient.cs @@ -1861,8 +1861,8 @@ private async Task TimeoutWrap(string name, Func action) if (await Task.WhenAny(timeoutTask, handlersTask).ConfigureAwait(false) == timeoutTask) { await _gatewayLogger.WarningAsync($"A {name} handler is blocking the gateway task.").ConfigureAwait(false); - await handlersTask.ConfigureAwait(false); //Ensure the handler completes } + await handlersTask.ConfigureAwait(false); //Ensure the handler completes } catch (Exception ex) {