Skip to content

Commit

Permalink
fix: ensure that exceptions will be logged
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
foxbot committed May 18, 2019
1 parent a44c13a commit f6e3200
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Discord.Net.WebSocket/DiscordSocketClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1861,8 +1861,8 @@ private async Task TimeoutWrap(string name, Func<Task> 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)
{
Expand Down

0 comments on commit f6e3200

Please sign in to comment.