-
Notifications
You must be signed in to change notification settings - Fork 745
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
It's not possible to get notification when a resource has been stopped/finished when after await app.StopAsync();.
I'm trying to write a test that uses a Docker Volume, and when the test is done, it deletes the volume. However, the volume is still in use even after await app.StopAsync(); returns, which means the container using the volume is still running.
I'd like a way to get notified when the resource/container is finished so I can delete the volume.
One reason this isn't possible today is that WaitForResourceAsync cancels once the app is stopping here:
| public async Task<string> WaitForResourceAsync(string resourceName, IEnumerable<string> targetStates, CancellationToken cancellationToken = default) | |
| { | |
| using var watchCts = CancellationTokenSource.CreateLinkedTokenSource(_applicationStopping, cancellationToken); | |
| var watchToken = watchCts.Token; | |
| await foreach (var resourceEvent in WatchAsync(watchToken).ConfigureAwait(false)) |
Once the app is stopping, it cancels this loop, which means we won't get more notifications about the resource.
Expected Behavior
I'd like to get a notification when the container is finished.
Steps To Reproduce
await using var app = await appHost.BuildAsync();
var resourceNotificationService = app.Services.GetRequiredService<ResourceNotificationService>();
await app.StartAsync();
await app.StopAsync();
await resourceNotificationService.WaitForResourceAsync("webfrontend", KnownResourceStates.Finished).WaitAsync(TimeSpan.FromSeconds(30));Exceptions (if any)
No response
.NET Version info
No response