Skip to content

Conversation

davidfowl
Copy link
Member

@davidfowl davidfowl commented Jul 13, 2025

Follow up to #10354

  • Previously we didn't preemptively dispatch to the threadpool per resource on startup. That causes issues blocking other resource's startup because of a single blocking call. This change dispatching preemptively before creating the dcp resource.

Reproduced while dogfooding the community toolkit with 9.4 builds. Verified this fix on the same build.

Hanging stack:

hangstack

- Previously we didn't preemptively dispatch to the threadpool per resource on startup. That causes issues blocking other resource's startup because of a single blocking call. This change dispatching preemptively before creating the dcp resource.
@davidfowl davidfowl requested review from Copilot, mitchdenny and karolz-ms and removed request for Copilot July 13, 2025 01:40
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR ensures that each resource startup dispatches asynchronously to avoid blocking other resources by preemptively yielding to the thread pool.

  • Inserted Task.Yield() at the start of CreateExecutableAsync to force asynchronous execution.
  • Inserted Task.Yield() at the start of CreateContainerAsync to force asynchronous execution.
Comments suppressed due to low confidence (2)

src/Aspire.Hosting/Dcp/DcpExecutor.cs:1100

  • [nitpick] Consider elaborating this comment to explain why Task.Yield() is necessary to prevent blocking other resource startups (e.g., avoiding thread-pool starvation).
        // Force async execution

src/Aspire.Hosting/Dcp/DcpExecutor.cs:1354

  • [nitpick] Consider expanding this comment to detail the rationale for forcing an asynchronous yield here, so future readers understand the threading implications.
        // Force async execution

@github-actions github-actions bot added the area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication label Jul 13, 2025
@davidfowl
Copy link
Member Author

/backport to release/9.4

Copy link
Contributor

Started backporting to release/9.4: https://github.com/dotnet/aspire/actions/runs/16244106437

@davidfowl davidfowl merged commit e026c5d into main Jul 13, 2025
277 checks passed
@davidfowl davidfowl deleted the davidfowl/force-async-execution branch July 13, 2025 02:01
@github-actions github-actions bot locked and limited conversation to collaborators Aug 12, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants