dotnet / aspire

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

Angular process started with AddNpmApp does not stop when host stops or when stop button is clicked on MacOS #6749

Open danroot opened 1 day ago

danroot commented 1 day ago

Is there an existing issue for this?

Describe the bug

I have an angular app set up in Aspire and working fine. However when I shut down the app host, the process is not stopped. When the app host is run again, a second process is started. Looking in Activity Manager, I see multiple 'ng serve' tasks. After repeated app host restarts, before I realized the cause, this has even resulted in out-of-memory issues on my laptop (M1 mac).

In addition, clicking 'stop' in the Aspire dashboard for the resource does not result in the process stopping. The UI shows 'command stop successful', and the resource log shows "Successfully executed command 'resource-stop'." The App Host log shows:

fail: Aspire.Hosting.Dcp.dcpctrl.os-executor[0]
      could not stop root process       {"root": 97599, "error": "context deadline exceeded"}
fail: Aspire.Hosting.Dcp.dcpctrl.ExecutableReconciler[0]
      could not stop the Executable     {"Executable": {"name":"spike-angularaspire-ui-ymchkcks"}, "Reconciliation": 11, "RunID": "97599", "error": "context deadline exceeded"}

App host

 builder.AddNpmApp("mycompany-project-webui", "../MyCompany.Project.WebUI", scriptName:"aspire-osx")
    .WithReference(api)
    .WithHttpsEndpoint(44304,env:"PORT")
    .WithExternalHttpEndpoints();

package.json:

 "aspire-osx": "ng serve --port $PORT --configuration=local",

Expected Behavior

Stopping the app host or clicking stop stops the process.

Steps To Reproduce

https://github.com/danroot/Spike.AngularAspire

I ran this in windows environment also and it behaved as expected, stopping the angular proces.

Exceptions (if any)

fail: Aspire.Hosting.Dcp.dcpctrl.os-executor[0]
      could not stop root process       {"root": 97599, "error": "context deadline exceeded"}
fail: Aspire.Hosting.Dcp.dcpctrl.ExecutableReconciler[0]
      could not stop the Executable     {"Executable": {"name":"spike-angularaspire-ui-ymchkcks"}, "Reconciliation": 11, "RunID": "97599", "error": "context deadline exceeded"}

.NET Version info

.NET SDK: Version: 9.0.100 Commit: 59db016f11 Workload version: 9.0.100-manifests.3068a692 MSBuild version: 17.12.7+5b8665660

Runtime Environment: OS Name: Mac OS X OS Version: 14.2 OS Platform: Darwin RID: osx-arm64 Base Path: /usr/local/share/dotnet/sdk/9.0.100/

Anything else?

No response