Skip to content

Fix extension CLI teardown during AppHost build - #20021

Draft
Ella Hathaway (ellahathaway) wants to merge 1 commit into
mainfrom
ellahathaway-fix-dynamic-debug-teardown
Draft

Fix extension CLI teardown during AppHost build#20021
Ella Hathaway (ellahathaway) wants to merge 1 commit into
mainfrom
ellahathaway-fix-dynamic-debug-teardown

Conversation

@ellahathaway

Copy link
Copy Markdown
Contributor

Description

Stopping a dynamic debug session could terminate the Aspire CLI while a cold single-file AppHost build was still running. On Windows, the orphaned dotnet build process retained the fixture workspace as its working directory, causing E2E teardown to fail with EBUSY.

This change routes extension stop requests through cooperative CLI cancellation so the existing child-process shutdown path runs. It also makes RunCommand drain pending pre-build work before returning from cancellation, preventing a late build from outliving the CLI.

Validation:

  • 111 RunCommandTests and ExtensionBackchannelTests passed.
  • The dynamic debug E2E passed 3/3 with a temporary 20-second AppHost build delay that reproduced the teardown lock before the fix.
  • The unmodified Windows dynamic-debug-configuration shard passed 3/3.

Fixes # (issue)

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No

Route extension stop requests through cooperative cancellation and wait for in-flight pre-build cleanup before the CLI exits.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 20021

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 20021"

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Tests selector

2 / 99 PR test projects · 4 PR jobs · 1 advisory-only target, from 5 changed files.

Selected PR test projects (2 / 99)

Aspire.Cli.EndToEnd.Tests, Aspire.Cli.Tests

Selected PR jobs (4)

cli-starter-validation, extension-e2e, polyglot, typescript-api-compat

Advisory workflow impact (1)

  • deployment-e2e (schedule/dispatch-only)

How these were chosen — grouped by what changed

📦 affected project Aspire.Cli
1 test: Aspire.Cli.EndToEnd.Tests

🧪 tests/Aspire.Cli.Tests/Backchannel/ExtensionBackchannelTests.cs (changed test)
1 directly: Aspire.Cli.Tests

🧪 tests/Aspire.Cli.Tests/Commands/RunCommandTests.cs (changed test)
1 directly: Aspire.Cli.Tests

🧪 tests/Aspire.Cli.Tests/Utils/CliTestHelper.cs (changed test)
1 directly: Aspire.Cli.Tests

Job reasons

Job Triggered by
cli-starter-validation affected project Aspire.Cli
deployment-e2e affected project Aspire.Cli
extension-e2e src/Aspire.Cli/Backchannel/ExtensionRpcTarget.cs, src/Aspire.Cli/Commands/RunCommand.cs, tests/Aspire.Cli.Tests/Backchannel/ExtensionBackchannelTests.cs, tests/Aspire.Cli.Tests/Commands/RunCommandTests.cs, tests/Aspire.Cli.Tests/Utils/CliTestHelper.cs
• affected project Aspire.Cli
polyglot affected project Aspire.Cli
typescript-api-compat affected project Aspire.Cli

Selection computed for commit 0424e9b.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The five-second cleanup timeout can still let a pending build outlive the CLI.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Routes extension stop requests through cooperative CLI cancellation and waits for AppHost build cleanup.

Changes:

  • Replaces immediate CLI termination with cancellation-manager signaling.
  • Adds pending build cleanup handling and regression tests.
File summaries
File Description
src/Aspire.Cli/Backchannel/ExtensionRpcTarget.cs Cooperatively cancels CLI execution.
src/Aspire.Cli/Commands/RunCommand.cs Waits for canceled pre-build work.
tests/Aspire.Cli.Tests/Backchannel/ExtensionBackchannelTests.cs Tests stop-request cancellation.
tests/Aspire.Cli.Tests/Commands/RunCommandTests.cs Tests cleanup ordering.
tests/Aspire.Cli.Tests/Utils/CliTestHelper.cs Supplies the cancellation manager.
Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 1
  • Review effort level: Balanced

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +680 to +686
if (!buildWaitCompleted &&
runCts is not null &&
runTask is not null &&
!runTask.IsCompleted)
{
await CancelAppHostStartupAsync(runCts, runTask, CancellationToken.None).ConfigureAwait(false);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants