Description
After upgrading the CommunityToolkit/Aspire repo from Aspire 13.5.0 to 13.6.0 (staging, 13.6.0+34db30a7d3733229da64a403dfc4e4e4d7a1a43b), one of our DbGate hosting tests now fails consistently on ubuntu-latest. DistributedApplication.StopAsync() throws TaskCanceledException after roughly 30 seconds. The same test passed on 13.5.0.
I wouldn't expect StopAsync to throw a timeout/cancellation exception at all. Even if stopping a resource takes a long time, the caller shouldn't get a TaskCanceledException out of StopAsync.
Failed run: https://github.com/CommunityToolkit/Aspire/actions/runs/36237790581/job/108392716621 (PR CommunityToolkit/Aspire#1625)
Test
The test starts an app with a single DbGate container, waits only for endpoints to be allocated, then stops the app. So StopAsync is called while the container is most likely still starting.
[Fact]
[RequiresDocker]
public async Task AddDbGateWithDefaultsAddsUrlAnnotations()
{
using var builder = TestDistributedApplicationBuilder.Create();
var dbgate = builder.AddDbGate("dbgate");
var tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
dbgate.OnResourceEndpointsAllocated((resource, @event, ct) =>
{
tcs.SetResult();
return Task.CompletedTask;
});
var app = await builder.BuildAsync();
await app.StartAsync();
await tcs.Task;
var urls = dbgate.Resource.Annotations.OfType<ResourceUrlAnnotation>();
Assert.Single(urls, u => u.DisplayText == "DbGate Dashboard");
await app.StopAsync(); // throws TaskCanceledException after ~30s on 13.6
}
AddDbGate adds a plain container resource (dbgate/dbgate image) with an HTTP endpoint. There's no health check and no WaitFor.
Failure
failed CommunityToolkit.Aspire.Hosting.DbGate.Tests.AddDbGateTests.AddDbGateWithDefaultsAddsUrlAnnotations (32s 801ms)
System.Threading.Tasks.TaskCanceledException : A task was canceled.
at Microsoft.Extensions.Hosting.Internal.Host.ForeachService[T](IEnumerable`1 services, CancellationToken token, Boolean concurrent, Boolean abortOnFirstException, List`1 exceptions, Func`3 operation)
at Microsoft.Extensions.Hosting.Internal.Host.StopAsync(CancellationToken cancellationToken)
at Aspire.Hosting.DistributedApplication.StopAsync(CancellationToken cancellationToken) in /_/src/Aspire.Hosting/DistributedApplication.cs:497
at CommunityToolkit.Aspire.Hosting.DbGate.Tests.AddDbGateTests.AddDbGateWithDefaultsAddsUrlAnnotations() in /home/runner/work/Aspire/Aspire/tests/CommunityToolkit.Aspire.Hosting.DbGate.Tests/AddDbGateTests.cs:600
Expected behavior
StopAsync completes (as it did on 13.5.0), even if a container is still starting when it's called.
Environment
- Aspire.Hosting 13.6.0 (staging,
34db30a7d3733229da64a403dfc4e4e4d7a1a43b); previously passing on 13.5.0
- .NET SDK 10.0.401
- GitHub Actions
ubuntu-latest (Ubuntu 24.04), Docker 28.0.4
Description
After upgrading the CommunityToolkit/Aspire repo from Aspire 13.5.0 to 13.6.0 (staging,
13.6.0+34db30a7d3733229da64a403dfc4e4e4d7a1a43b), one of our DbGate hosting tests now fails consistently onubuntu-latest.DistributedApplication.StopAsync()throwsTaskCanceledExceptionafter roughly 30 seconds. The same test passed on 13.5.0.I wouldn't expect
StopAsyncto throw a timeout/cancellation exception at all. Even if stopping a resource takes a long time, the caller shouldn't get aTaskCanceledExceptionout ofStopAsync.Failed run: https://github.com/CommunityToolkit/Aspire/actions/runs/36237790581/job/108392716621 (PR CommunityToolkit/Aspire#1625)
Test
The test starts an app with a single DbGate container, waits only for endpoints to be allocated, then stops the app. So
StopAsyncis called while the container is most likely still starting.AddDbGateadds a plain container resource (dbgate/dbgateimage) with an HTTP endpoint. There's no health check and noWaitFor.Failure
Expected behavior
StopAsynccompletes (as it did on 13.5.0), even if a container is still starting when it's called.Environment
34db30a7d3733229da64a403dfc4e4e4d7a1a43b); previously passing on 13.5.0ubuntu-latest(Ubuntu 24.04), Docker 28.0.4