dotnet / aspire

Tools, templates, and packages to accelerate building observable, production-ready apps
https://learn.microsoft.com/dotnet/aspire
MIT License
3.92k stars 479 forks source link

Aspire 9 preview 1 processes take long time to shut down #6437

Closed jack775544 closed 2 weeks ago

jack775544 commented 1 month ago

Is there an existing issue for this?

Describe the bug

I have an Aspire project that contains a mix of container resources, executable resources (all running node) and project resources. After testing Aspire 9 preview 1, I have noticed that on shutting down the app host, the non container resources take a considerable time to shut down or in some cases, do not shut down at all. This also includes the dashboard process not shutting down as well.

In my project, I have no persistent resources.

Expected Behavior

After shutting down the app host, all services should be shut down.

Steps To Reproduce

Exceptions (if any)

No response

.NET Version info

.NET SDK:
 Version:           8.0.403
 Commit:            c64aa40a71
 Workload version:  8.0.400-manifests.c15ea148
 MSBuild version:   17.11.9+a69bbaaf5

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.22631
 OS Platform: Windows
 RID:         win-x64
 Base Path:   C:\Program Files\dotnet\sdk\8.0.403\

.NET workloads installed:
Configured to use loose manifests when installing new manifests.
 [aspire]
   Installation Source: VS 17.11.35327.3
   Manifest Version:    8.2.0/8.0.100
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.aspire\8.2.0\WorkloadManifest.json
   Install Type:        FileBased

Host:
  Version:      8.0.10
  Architecture: x64
  Commit:       81cabf2857

.NET SDKs installed:
  6.0.427 [C:\Program Files\dotnet\sdk]
  8.0.206 [C:\Program Files\dotnet\sdk]
  8.0.403 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.35 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 8.0.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 8.0.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.35 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 8.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 8.0.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 6.0.35 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 7.0.7 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 8.0.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 8.0.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
  x86   [C:\Program Files (x86)\dotnet]
    registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
  Not set

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download

Anything else?

I have seen this behaviour from running the AppHost from the command line and from Rider.

davidfowl commented 1 month ago

See https://github.com/dotnet/aspire/issues/6221#issuecomment-2408002558, this should be fixed in later builds.

jack775544 commented 1 month ago

See #6221 (comment), this should be fixed in later builds.

Sounds good. The only thing different from that ticket is that I am also getting this for project resources and the dashboard as well.

davidfowl commented 1 month ago

Sounds good. The only thing different from that ticket is that I am also getting this for project resources and the dashboard as well.

Can you reproduce this with a new started project?

jack775544 commented 1 month ago

I just gave it a go on a new project by doing dotnet new aspire-starter and upgrading it to 9.0.0-rc.1.24511.1.

Shutting down the project worked fine there.

I then added a node project and after that it caused the project resources to not stop correctly. My test repo is here, though it sounds like this problem is pretty well understood at this point https://github.com/jack775544/AspireStopBug

davidfowl commented 1 month ago

Seems like the same problem. If you want to try out a newer build, you can try:

dotnet new install Aspire.ProjectTemplates::9.0.0-rc2* --force

You'll get new templates with the fix.

davidfowl commented 1 month ago

You should be able to switch back to the RC1 templates easily as well

joperezr commented 3 weeks ago

@jack775544 Can you confirm that using newer templates fixed the issue for you?

jsheetzmt commented 3 weeks ago

Any tricks to use RC2? Trying to install the templates and getting an error back

Image

davidfowl commented 3 weeks ago

@jsheetzmt Do you have the right feeds set up? https://github.com/dotnet/aspire/blob/main/docs/using-latest-daily.md

jsheetzmt commented 3 weeks ago

I have this for my nuget.config. Also tried https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet9/nuget/v3/index.json (updated dotnet8 to dotnet9)

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <packageSources>
        <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
        <add key="aspire" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet8/nuget/v3/index.json" />
    </packageSources>
    <packageSourceMapping>
        <packageSource key="nuget.org">
            <package pattern="*" />
        </packageSource>
        <packageSource key="aspire">
            <package pattern="Aspire.*" />
            <package pattern="Microsoft.Extensions.ServiceDiscovery*" />
        </packageSource>
    </packageSourceMapping>
</configuration>
jsheetzmt commented 3 weeks ago

dotnet new install Aspire.ProjectTemplates::9.0.0-rc2* --force command isn't working but with the feeds setup, I can at least upgrade the packages using Manage Nuget Packages

However, still have this error when attempting to build: Error (active) MSB4236 The SDK 'Aspire.AppHost.Sdk/9.0.0-rc.2.24519.2' specified could not be found.

jack775544 commented 3 weeks ago

@jack775544 Can you confirm that using newer templates fixed the issue for you?

I am out of town without a computer right now but I will be able to test it out next week.

jack775544 commented 2 weeks ago

I have attempted to confirm this but I can't upgrade to the rc2 version as described, similar to the others in the thread. To rule out any local config I tried downloading the templates into a dotnet sdk docker container and got the same error.

❯ docker run -it --rm -v .:/app mcr.microsoft.com/dotnet/sdk:8.0 bin/bash
root@d157f277f8f3:/# dotnet nuget add source --name dotnet9 https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet9/nuget/v3/index.json
Package source with Name: dotnet9 added successfully.
root@d157f277f8f3:/# dotnet new install Aspire.ProjectTemplates::9.0.0-rc2* --force
The following template packages will be installed:
   Aspire.ProjectTemplates::9.0.0-rc2*

Aspire.ProjectTemplates::9.0.0-rc2* could not be installed, the package does not exist.

For details on the exit code, refer to https://aka.ms/templating-exit-codes#103
root@d157f277f8f3:/#
davidfowl commented 2 weeks ago

Try out 9.1.0-*

davidfowl commented 2 weeks ago

The instructions have been updated https://github.com/dotnet/aspire/blob/main/docs/using-latest-daily.md

jack775544 commented 2 weeks ago

Thanks for the help. I just tried it using version 9.1.0-preview.1.24553.1 and my services are now shutting down correctly.

joperezr commented 2 weeks ago

Thanks for confirming. Closing.