Skip to content

Commit

Permalink
Extensions: fix failure to await DisposeAsync() before flushing logs
Browse files Browse the repository at this point in the history
  • Loading branch information
wjrogers committed Nov 29, 2023
1 parent f24ef18 commit 78dae16
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions XO.Console.Cli.Extensions/CommandAppHostBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,19 @@ await DisposeAndFlush(host, loggerFactory)
return result;
}

private static ValueTask DisposeAndFlush(IHost host, ILoggerFactory? loggerFactory)
private static async ValueTask DisposeAndFlush(IHost host, ILoggerFactory? loggerFactory)
{
try
{
if (host is IAsyncDisposable asyncDisposable)
return asyncDisposable.DisposeAsync();

host.Dispose();
return ValueTask.CompletedTask;
{
await asyncDisposable.DisposeAsync()
.ConfigureAwait(false);
}
else
{
host.Dispose();
}
}
finally
{
Expand Down

0 comments on commit 78dae16

Please sign in to comment.