`WaitForResourceHealthyAsync` should fail fast if Resource does not exist
- 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
If in a test you try to wait on a resource that doesn't exist in a test, it will hang indefinitely until the test times out. (You did remember to include cancellation right 😢)
### Expected Behavior
I'd expect this attempt to wait to fail fast if the resource doesn't exist in the model.
### Steps To Reproduce
Take the default test from the starter templates, and throw in a `await app.ResourceNotifications.WaitForResourceHealthyAsync("DOESNOTEXIST")` call, pointing to a resource that doesn't exist
```
public async Task GetWebResourceRootReturnsOkStatusCode()
{
// Arrange
var appHost = await DistributedApplicationTestingBuilder.CreateAsync();
appHost.Services.AddLogging(logging =>
{
logging.SetMinimumLevel(LogLevel.Debug);
// Override the logging filters from the app's configuration
logging.AddFilter(appHost.Environment.ApplicationName, LogLevel.Debug);
logging.AddFilter("Aspire.", LogLevel.Debug);
});
appHost.Services.ConfigureHttpClientDefaults(clientBuilder =>
{
clientBuilder.AddStandardResilienceHandler();
});
await using var app = await appHost.BuildAsync().WaitAsync(DefaultTimeout);
await app.StartAsync().WaitAsync(DefaultTimeout);
// Act
await app.ResourceNotifications.WaitForResourceHealthyAsync("DOESNOTEXIST").WaitAsync(DefaultTimeout);
}
```
### Exceptions (if any)
Logs:
```
Aspire.Hosting.DistributedApplication[0]
Aspire version: 9.1.0+2a8f48ea5811f317a26405eb315aa315cc9e3cea
Aspire.Hosting.DistributedApplication[0]
Distributed application starting.
Aspire.Hosting.DistributedApplication[0]
Application host directory is: S:\aspire91\aspire91.AppHost
Aspire.Hosting.DistributedApplication[0]
Distributed application started. Press Ctrl+C to shut down.
Aspire.Hosting.ApplicationModel.ResourceNotificationService[0]
Waiting for resource 'DOESNOTEXIST' to enter the 'Healthy' state.
```
### .NET Version info
_No response_
### Anything else?
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.