Skip to content

App host shutdown - "Hosting failed to start" error message #6314

Closed

Description

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

If I CTRL+C the app host just after it starts up in TestShop I see this error in the console:

fail: Microsoft.Extensions.Hosting.Internal.Host[11]
      Hosting failed to start
      System.Threading.Tasks.TaskCanceledException: A task was canceled.
         at System.Text.Json.Utf8JsonWriter.FlushAsync(CancellationToken cancellationToken)
         at Aspire.Hosting.RedisBuilderExtensions.<WithRedisInsight>g__ImportRedisDatabases|2_0(ILogger resourceLogger, IEnumerable`1 redisInstances, HttpClient client, CancellationToken ct) in C:\Development\Source\aspire\src\Aspire.Hosting.Redis\RedisBuilderExtensions.cs:line 209
         at Aspire.Hosting.RedisBuilderExtensions.<>c__DisplayClass2_1.<<WithRedisInsight>b__1>d.MoveNext() in C:\Development\Source\aspire\src\Aspire.Hosting.Redis\RedisBuilderExtensions.cs:line 175
      --- End of stack trace from previous location ---
         at Aspire.Hosting.Eventing.DistributedApplicationEventing.<>c__DisplayClass4_0`1.<<Subscribe>b__0>d.MoveNext() in C:\Development\Source\aspire\src\Aspire.Hosting\Eventing\DistributedApplicationEventing.cs:line 82
      --- End of stack trace from previous location ---
         at Aspire.Hosting.Eventing.DistributedApplicationEventing.PublishAsync[T](T event, EventDispatchBehavior dispatchBehavior, CancellationToken cancellationToken) in C:\Development\Source\aspire\src\Aspire.Hosting\Eventing\DistributedApplicationEventing.cs:line 69
         at Aspire.Hosting.Dcp.ApplicationExecutor.RunApplicationAsync(CancellationToken cancellationToken) in C:\Development\Source\aspire\src\Aspire.Hosting\Dcp\ApplicationExecutor.cs:line 148
         at Aspire.Hosting.Dcp.DcpHostService.StartAsync(CancellationToken cancellationToken) in C:\Development\Source\aspire\src\Aspire.Hosting\Dcp\DcpHostService.cs:line 75
         at Microsoft.Extensions.Hosting.Internal.Host.<StartAsync>b__15_1(IHostedService service, CancellationToken token)
         at Microsoft.Extensions.Hosting.Internal.Host.ForeachService[T](IEnumerable`1 services, CancellationToken token, Boolean concurrent, Boolean abortOnFirstException, List`1 exceptions, Func`3 operation)

I think this is related to #6038. The problem is starting the app host is waiting on user code and wait fors. It shouldn't be. These things should happen in another task.

Expected Behavior

No error.

Steps To Reproduce

  1. Start TestShop
  2. Don't have Docker running
  3. CTRL+C host
  4. Host shuts down and prints error

Exceptions (if any)

No response

.NET Version info

No response

Anything else?

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    area-app-modelIssues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions