microsoft / microsoft/aspire

Resource waiting on itself deadlocks, and breaks `aspire start`

Open
#17,758 3 comments 0 reactions 1 assignee Claimed by @karolz-ms View on GitHub
area-app-model area-cli 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

I had a bizarre issue where `aspire run` worked fine, but `aspire start` was hanging until it timed out. Whilst `aspire start` was hanging, I couldn't even to an `aspire ps` to see what was going on. This caused my agent to have a lot of problems working out what the problem was.

I eventually tracked the problem down to managing to cause a resource to wait on itself. (specifically in the community toolkit causing the Otel collector to wait on itself)

### Expected Behavior

There are a few things wrong here:

1. A resource waiting on itself shouldn't deadlock (or should throw an error earlier)
2. A resource stuck in the `waiting` state shouldnt' cause `aspire start` to fail.
3. Even if `aspire start` waits for something, `aspire ps` or other commands should work whilst resources start up so an agent has a chance to troubleshoot the problem if there are problems.

### Steps To Reproduce

```cs
var builder = DistributedApplication.CreateBuilder(args);

var x = builder.AddContainer("nginx", "nginx")
.WithHttpEndpoint(targetPort: 80);

// This throws
// x.WaitFor(x);

// But this does not, and causes the resource to wait infinitely
// as well as blocking `aspire start`
x.WithAnnotation(new WaitAnnotation(x.Resource, WaitType.WaitUntilHealthy));

builder.Build().Run();
```

### Exceptions (if any)

_No response_

### Aspire doctor output

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

Aspire
⚠️ Aspire CLI version 13.4.0-preview.1.26271.17 (channel: daily) is out of date. Latest version is 13.5.0-preview.1.26281.1 (channel: prerelease)
Run 'aspire update' to update Aspire CLI.

.NET SDK
✅ .NET 10.0.103 installed (arm64)

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

Environment
✅ HTTPS development certificate is trusted
⚠️ HTTPS development certificate has an older version (v5)
Run 'aspire certs clean' to remove all certificates, then run 'aspire certs trust' to create and trust a new one.
See: https://aka.ms/aspire-prerequisites#dev-certs
Details:
Older certificate versions (< v4) may not support all certificate trust scenarios.

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

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

╭──────────────────────────────────────────┬────────────────────────────────────────────────────────────────────┬─────────┬───────────┬─────────────╮
│ Path │ Version │ Channel │ Route │ PATH status │
├──────────────────────────────────────────┼────────────────────────────────────────────────────────────────────┼─────────┼───────────┼─────────────┤
│ /Users/alex/.aspire/bin/aspire (current) │ 13.4.0-preview.1.26271.17+b5ce100e0b30660a9e33ba757adf098aad9ffc92 │ daily │ (unknown) │ active │
╰──────────────────────────────────────────┴────────────────────────────────────────────────────────────────────┴─────────┴───────────┴─────────────╯
```

### Anything else?

_No response_

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.