microsoft / microsoft/aspire

ExecuteCommandAsync "stop" hangs indefinitely when ProjectResource is in Waiting state

Open
#18,282 2 comments 0 reactions 1 assignee Claimed by @karolz-ms View on GitHub
area-app-model triage:bot-seen
Dominant language
C#
Stars
6.3k
Forks
991
Avg merge
2d 15h
Merged PRs (30d)
196

Description

### Is there an existing issue for this?

- [x] I have searched the existing issues

### Describe the bug

When calling `resourceCommandService.ExecuteCommandAsync(resource, "stop", cancellationToken)` on a `ProjectResource` that is in a Waiting state, the task never completes. Awaiting all stop tasks via `Task.WhenAll` therefore deadlocks, blocking any code that runs after the stop phase.

This surfaces in practice when a dashboard command tries to stop all project resources before performing a database operation (e.g. a bacpac import). If one or more projects are waiting on another resource (for example, the database), the stop command hangs for those resources and the import never proceeds and we end up with a deadlock.

### Expected Behavior

Sending a `"stop"` command to a resource that is waiting for another resource to start before it can start itself, should be stop the waiting. `Task.WhenAll` should complete once all resources are confirmed stopped.

### Steps To Reproduce

https://github.com/sander1095/aspire-waiting-hanging-bug

### Exceptions (if any)

_No response_

### Aspire doctor output

Aspire Environment Check
========================

Aspire
⚠️ Aspire CLI version 13.4.3 (channel: stable) is out of date. Latest version is 13.4.5 (channel:
stable)
Run 'aspire update' to update Aspire CLI.

AppHost
✅ AppHost version 13.4.3 (src\Aspire.AppHost\Aspire.AppHost.csproj)

.NET SDK
✅ .NET 10.0.103 installed (x64)

Container Runtime
✅ Docker v28.5.1: running (auto-detected (default)) ← active

Environment
✅ HTTPS development certificate is trusted

Summary: 4 passed, 1 warnings, 0 failed
For detailed prerequisites: https://aka.ms/aspire-prerequisites

Aspire CLI Installations
========================

╭────────────────────────────────┬───────────────────────────────┬─────────┬───────────┬─────────────╮
│ Path │ Version │ Channel │ Route │ PATH status │
├────────────────────────────────┼───────────────────────────────┼─────────┼───────────┼─────────────┤
│ C:\Users\stenb\.aspire\bin\asp │ 13.4.3+4f218933552e18ff2874d1 │ stable │ (unknown) │ active │
│ ire.exe (current) │ b6d5dc3fe671e3b6d9 │ │ │ │
╰────────────────────────────────┴───────────────────────────────┴─────────┴───────────┴─────────────╯

### Anything else?

This bug is the immediate trigger for feature request #18280, which asks for a dependency-aware stop/start API so that commands like a bacpac import only need to stop the resources that actually depend on the target database, making the hung-stop scenario less likely and the overall pattern more robust.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.