Skip to content

Commit

Permalink
Properly completing Responder task and making sure handler exceptions…
Browse files Browse the repository at this point in the history
… bubble up

Resolves #52
  • Loading branch information
Simon Oxtoby committed Jun 14, 2020
1 parent bd6e7b8 commit 0b5fd5d
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions SlackNet.AspNetCore/SlackRequestHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,19 @@ private static async Task<SlackResult> RespondAsync<T>(Func<Responder<T>, Task>

var firstCompletedTask = await Task.WhenAny(earlyResponse.Task, handlingComplete).ConfigureAwait(false);

return firstCompletedTask == earlyResponse.Task
? earlyResponse.Task.Result.OnCompleted(() => handlingComplete)
: defaultResult();
if (firstCompletedTask == earlyResponse.Task)
{
return earlyResponse.Task.Result.OnCompleted(() =>
{
requestComplete.SetResult(0);
return handlingComplete;
});
}
else
{
await handlingComplete.ConfigureAwait(false); // Fish for exception
return defaultResult();
}
}

public async Task<SlackResult> HandleOptionsRequest(HttpRequest request, SlackEndpointConfiguration config)
Expand Down

0 comments on commit 0b5fd5d

Please sign in to comment.