z4kn4fein / stashbox-extensions-dependencyinjection

Stashbox Integration for ASP.NET Core, .NET Generic Host and ServiceCollection based applications.
https://z4kn4fein.github.io/stashbox
MIT License
17 stars 2 forks source link

Stashbox causes IHost Shutdown to be blocked. #7

Closed Nikey646 closed 3 years ago

Nikey646 commented 3 years ago

Reproduction Code:

public static async Task Main(String[] args)
{
    await Host.CreateDefaultBuilder()
        .UseStashbox()
        .RunConsoleAsync();
    Console.WriteLine("Application Shutdown Expected?");
}

Async / Sync methods of the IHost interface don't change the result. Manually building and running don't change the result. Commenting out line 4 in the example results in the application shutting down as expected.

Setting the Environment to Development or Production doesn't change the result.

Example log from Stashbox blocking the IHost Shutdown:

info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Hosting environment: Production
info: Microsoft.Hosting.Lifetime[0]
      Content root path: C:\Projects\CSharp\Discord Bots\Kuuhaku\src\Kuuhaku\bin\Debug\netcoreapp3.1
info: Microsoft.Hosting.Lifetime[0]
      Application is shutting down...
Application Shutdown Expected?
info: Microsoft.Hosting.Lifetime[0]
      Waiting for the host to be disposed. Ensure all 'IHost' instances are wrapped in 'using' blocks.

When .UseStashbox() is commented out, the output is the same minus the last log message, and the application immediately exits after the Application Shutdown Expected? message appears.

Nuget References is only Stashbox.Extensions.Hosting at version 2.9.4.

Nikey646 commented 3 years ago

Rolling back to Version 2.8.0 2.9.0 of Stashbox.Extensions.Hosting results in the expected outcome (Application shuts down)

Nikey646 commented 3 years ago

By incrementally upgrading from 2.9.0 and testing the minimal example, it appears that changes in the Stashbox project version 3.3.2, or the Custom Service Provider that was added in 2.9.4 is what is causing the issue.

Related commit: https://github.com/z4kn4fein/stashbox-extensions-dependencyinjection/commit/ac3482241408301b89171c5c729e9d6cb68ebfab

z4kn4fein commented 3 years ago

Thanks for reporting the issue, I'm going to check it soon!

z4kn4fein commented 3 years ago

Published a new version with the fix, could you please confirm that it works on your side as well? Thanks!

Nikey646 commented 3 years ago

Published a new version with the fix, could you please confirm that it works on your side as well? Thanks!

Works great, thank you very much!