Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 additions & 11 deletions src/Aspire.Hosting/Dcp/DcpExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ private async Task CreateContainersAndExecutablesAsync(CancellationToken cancell
var containersTask = CreateContainersAsync(toCreate.Where(ar => ar.DcpResource is Container), cancellationToken);
var executablesTask = CreateExecutablesAsync(toCreate.Where(ar => ar.DcpResource is Executable), cancellationToken);

await Task.WhenAll(containersTask, executablesTask).ConfigureAwait(false);
await Task.WhenAll(containersTask, executablesTask).WaitAsync(cancellationToken).ConfigureAwait(false);
}

private void AddAllocatedEndpointInfo(IEnumerable<AppResource> resources)
Expand Down Expand Up @@ -1084,10 +1084,10 @@ async Task CreateResourceExecutablesAsyncCore(IResource resource, IEnumerable<Ap
var tasks = new List<Task>();
foreach (var group in executableResources.GroupBy(e => e.ModelResource))
{
tasks.Add(CreateResourceExecutablesAsyncCore(group.Key, group, cancellationToken));
tasks.Add(Task.Run(() => CreateResourceExecutablesAsyncCore(group.Key, group, cancellationToken), cancellationToken));
}

return Task.WhenAll(tasks);
return Task.WhenAll(tasks).WaitAsync(cancellationToken);
Copy link

Copilot AI Jul 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is declared to return Task but returns a ValueTask from WaitAsync. You should await the WaitAsync inside the async method (with .ConfigureAwait(false)) instead of returning it directly.

Suggested change
return Task.WhenAll(tasks).WaitAsync(cancellationToken);
return await Task.WhenAll(tasks).WaitAsync(cancellationToken).ConfigureAwait(false);

Copilot uses AI. Check for mistakes.
}
finally
{
Expand All @@ -1097,9 +1097,6 @@ async Task CreateResourceExecutablesAsyncCore(IResource resource, IEnumerable<Ap

private async Task CreateExecutableAsync(AppResource er, ILogger resourceLogger, CancellationToken cancellationToken)
{
// Force async execution
await Task.Yield();

if (er.DcpResource is not Executable exe)
{
throw new InvalidOperationException($"Expected an Executable resource, but got {er.DcpResource.Kind} instead");
Expand Down Expand Up @@ -1338,10 +1335,10 @@ async Task CreateContainerAsyncCore(AppResource cr, CancellationToken cancellati
}
}

tasks.Add(CreateContainerAsyncCore(cr, cancellationToken));
tasks.Add(Task.Run(() => CreateContainerAsyncCore(cr, cancellationToken), cancellationToken));
}

await Task.WhenAll(tasks).ConfigureAwait(false);
await Task.WhenAll(tasks).WaitAsync(cancellationToken).ConfigureAwait(false);
}
finally
{
Expand All @@ -1351,9 +1348,6 @@ async Task CreateContainerAsyncCore(AppResource cr, CancellationToken cancellati

private async Task CreateContainerAsync(AppResource cr, ILogger resourceLogger, CancellationToken cancellationToken)
{
// Force async execution
await Task.Yield();

await _executorEvents.PublishAsync(new OnResourceStartingContext(cancellationToken, KnownResourceTypes.Container, cr.ModelResource, cr.DcpResource.Metadata.Name)).ConfigureAwait(false);

var dcpContainerResource = (Container)cr.DcpResource;
Expand Down
Loading