Skip to content

Don't count AppHost builds against CLI startup timeout - #19478

Merged
Ella Hathaway (ellahathaway) merged 19 commits into
mainfrom
ellahathaway-fix-cli-startup-timeout
Sep 4, 2026
Merged

Don't count AppHost builds against CLI startup timeout#19478
Ella Hathaway (ellahathaway) merged 19 commits into
mainfrom
ellahathaway-fix-cli-startup-timeout

Conversation

@ellahathaway

@ellahathaway Ella Hathaway (ellahathaway) commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Description

Long restores and builds could exhaust ASPIRE_CLI_START_TIMEOUT before the AppHost process started. This caused aspire run and detached aspire start to report a misleading startup timeout for cold or large solutions.

This change:

  • starts the foreground startup budget after successful AppHost preparation;
  • prevents the detached launcher from consuming the budget while its child restores and builds;
  • observes an AppHost project that faults or exits before signaling preparation completion, avoiding an unbounded wait;
  • excludes guest dependency installation, pre-execute checks, and extension-owned builds from the startup budget;
  • pre-builds file-based AppHosts with CLI run-hook suppression, then reuses that output with dotnet run --no-build --file;
  • moves the mandatory file-based safety build for explicit --no-build before the startup budget begins;
  • pre-builds file-based AppHosts before publish/deploy execution so fresh and edited models cannot use missing or stale cached output;
  • preserves the safe rebuilding fallback for explicit file-based publish --no-build;
  • preserves normal Ctrl+C cancellation semantics during build and guest preparation.

User-facing usage

The existing configuration now applies only to AppHost startup after build completion:

$env:ASPIRE_CLI_START_TIMEOUT = "15"
aspire start --no-build

A required safety build may take longer than fifteen seconds; once it completes, the AppHost receives the full fifteen-second startup budget.

Validation

  • Merged current main and verified head ad625f529ecdd07eb693fe0ecc5ac4f88359951d.
  • Installed the exact Windows ARM64 dogfood CLI: 13.6.0-pr.19478.gad625f52.
  • Verified foreground aspire run succeeds when a 20-second file build exceeds a 15-second startup budget; describe and stop succeeded.
  • Verified detached aspire start --no-build succeeds after a 20-second mandatory safety build with a 15-second budget; describe and stop succeeded.
  • Verified a post-build startup hang still emits ASPIRE_CLI_START_TIMEOUT guidance, exits non-zero, and leaves no running AppHost.
  • Verified fresh file-based publish executes current source.
  • Verified edited file-based publish advances from source marker v1 to v2 instead of using stale output.
  • Verified fresh explicit publish --no-build performs the safe fallback build and executes current source.
  • Verified the newest returned-cancellation and detached-timeout-cleanup unit regressions pass on the merged tree.
  • Added focused unit and Hex1b CLI E2E regression coverage; the repository E2E suite was not rerun locally.

Fixes #19255

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

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 4577bfec-d13e-49b2-a81e-abaa6ef4303d
Copilot AI balanced review requested due to automatic review settings August 18, 2026 19:13
@github-actions

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 -- 19478

Or

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

@github-actions

This comment has been minimized.

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.

Pull request overview

Separates AppHost build time from CLI startup timeout accounting and reuses safely prebuilt single-file output.

Changes:

  • Starts startup timeout accounting after build preparation.
  • Defers detached-launch timeout until backchannel connection.
  • Adds unit and CLI E2E regression coverage.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/Aspire.Cli/Commands/RunCommand.cs Moves startup timer after build signaling.
src/Aspire.Cli/Commands/AppHostLauncher.cs Delays detached readiness timeout.
src/Aspire.Cli/Projects/DotNetAppHostProject.cs Tracks CLI-built output for reuse.
src/Aspire.Cli/DotNet/DotNetCliRunner.cs Suppresses run hooks during builds.
tests/Aspire.Cli.Tests/Commands/RunCommandTests.cs Tests post-build timeout accounting.
tests/Aspire.Cli.Tests/Commands/AppHostLauncherTests.cs Tests detached long-build behavior.
tests/Aspire.Cli.Tests/Projects/DotNetAppHostProjectTests.cs Updates single-file rebuild expectations.
tests/Aspire.Cli.Tests/DotNet/DotNetCliRunnerTests.cs Tests suppression and --no-build.
tests/Aspire.Cli.EndToEnd.Tests/StartStopTests.cs Adds slow single-file build regression coverage.
Suppressed comments (1)

src/Aspire.Cli/Commands/RunCommand.cs:378

  • This timestamp still precedes builds performed inside _runner.RunAsync. DotNetAppHostProject signals build completion at line 1525, but file-based --no-build/extension-owned paths then force noBuild = false, and watch mode also runs with builds enabled. Those builds can therefore still exhaust ASPIRE_CLI_START_TIMEOUT, contrary to the new post-build contract. Complete any required build before signaling BuildCompletionSource, or introduce a separate signal emitted when the actual AppHost process starts.
            var startupStartTimestamp = _timeProvider.GetTimestamp();

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

Comment thread src/Aspire.Cli/Commands/RunCommand.cs
@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 4577bfec-d13e-49b2-a81e-abaa6ef4303d
Copilot AI review requested due to automatic review settings August 18, 2026 20:20

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.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.

@github-actions

This comment has been minimized.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 4577bfec-d13e-49b2-a81e-abaa6ef4303d
Copilot AI review requested due to automatic review settings August 18, 2026 21:02
@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

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.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.

Suppressed comments (1)

src/Aspire.Cli/Projects/DotNetAppHostProject.cs:1582

  • BuildCompletionSource is signaled before this fallback reaches dotnet run, so a file-based aspire run --no-build still starts ASPIRE_CLI_START_TIMEOUT before the mandatory safety rebuild (noBuild = false). If that rebuild exceeds the configured budget, the command reports the same misleading startup timeout this PR is intended to remove. Move this fallback build into the CLI preparation phase, or add a runner signal that marks its build complete before starting the startup budget.
            if (isSingleFileAppHost && !builtByCli)
            {
                // File-based RunCommand metadata is only safe to reuse when the CLI's pre-build
                // generated it with run-hook suppression. Preserve the existing rebuild behavior
                // for --no-build and extension-owned builds rather than trusting ambient output.
                noBuild = false;
                noRestore = false;

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

This comment has been minimized.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 4577bfec-d13e-49b2-a81e-abaa6ef4303d
Copilot AI review requested due to automatic review settings August 18, 2026 21:42

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.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.

@github-actions

This comment has been minimized.

Copilot AI review requested due to automatic review settings August 27, 2026 17:10
Ensure explicit publish --no-build creates safe current run metadata before local or VS Code extension delegation.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 4577bfec-d13e-49b2-a81e-abaa6ef4303d
@github-actions

This comment has been minimized.

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.

Pull request overview

Copilot reviewed 21 out of 21 changed files in this pull request and generated 1 comment.

Comment thread src/Aspire.Cli/Projects/DotNetAppHostProject.cs
@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

Exercise fresh --no-build publish and verify edited source produces updated Radius artifacts instead of stale output.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 4577bfec-d13e-49b2-a81e-abaa6ef4303d
Copilot AI review requested due to automatic review settings August 27, 2026 17:53
@github-actions

This comment has been minimized.

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.

Pull request overview

Copilot reviewed 22 out of 22 changed files in this pull request and generated no new comments.

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

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

Copilot-Session: 95635e33-3339-44d7-8dc9-2d8d80e9a4a5
Copilot AI review requested due to automatic review settings September 2, 2026 19:41
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 95635e33-3339-44d7-8dc9-2d8d80e9a4a5

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.

🟢 Approval recommended

The timeout lifecycle changes are consistently implemented and covered by focused unit and end-to-end regressions.

Review details
  • Files reviewed: 22/22 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Tests selector

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

Selected PR test projects (2 / 99)

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

Selected PR jobs (3)

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.EndToEnd.Tests/AppHostSyntaxErrorOutputTests.cs (changed test)
1 directly: Aspire.Cli.EndToEnd.Tests

🧪 tests/Aspire.Cli.EndToEnd.Tests/RadiusPublishTests.cs (changed test)
1 directly: Aspire.Cli.EndToEnd.Tests

🧪 tests/Aspire.Cli.EndToEnd.Tests/StartStopTests.cs (changed test)
1 directly: Aspire.Cli.EndToEnd.Tests

🧪 tests/Aspire.Cli.Tests/Commands/AppHostLauncherTests.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/DotNet/DotNetCliRunnerTests.cs (changed test)
1 directly: Aspire.Cli.Tests

🧪 tests/Aspire.Cli.Tests/DotNet/ProcessInvocationOptionsTests.cs (changed test)
1 directly: Aspire.Cli.Tests

🧪 tests/Aspire.Cli.Tests/Projects/DotNetAppHostProjectTests.cs (changed test)
1 directly: Aspire.Cli.Tests

🧪 tests/Aspire.Cli.Tests/Projects/GuestAppHostProjectTests.cs (changed test)
1 directly: Aspire.Cli.Tests

🧪 tests/Aspire.Cli.Tests/Templating/DotNetTemplateFactoryTests.cs (changed test)
1 directly: Aspire.Cli.Tests

🧪 tests/Aspire.Cli.Tests/TestServices/FakeAppHostServerSession.cs (changed test)
1 directly: Aspire.Cli.Tests

🧪 tests/Aspire.Cli.Tests/TestServices/TestAppHostStopper.cs (changed test)
1 directly: Aspire.Cli.Tests

🧪 tests/Aspire.Cli.Tests/TestServices/TestDotNetCliRunner.cs (changed test)
1 directly: Aspire.Cli.Tests

🧪 tests/Aspire.Cli.Tests/TestServices/TestExtensionInteractionService.cs (changed test)
1 directly: Aspire.Cli.Tests

Job reasons

Job Triggered by
deployment-e2e affected project Aspire.Cli
extension-e2e src/Aspire.Cli/Commands/AppHostLauncher.cs, src/Aspire.Cli/Commands/RunCommand.cs, src/Aspire.Cli/DotNet/DotNetCliRunner.cs, src/Aspire.Cli/Processes/IAppHostStopper.cs, src/Aspire.Cli/Program.cs, src/Aspire.Cli/Projects/DotNetAppHostProject.cs, src/Aspire.Cli/Projects/GuestAppHostProject.cs, src/Aspire.Cli/Utils/AppHostHelper.cs, tests/Aspire.Cli.EndToEnd.Tests/AppHostSyntaxErrorOutputTests.cs, tests/Aspire.Cli.EndToEnd.Tests/RadiusPublishTests.cs, tests/Aspire.Cli.EndToEnd.Tests/StartStopTests.cs, tests/Aspire.Cli.Tests/Commands/AppHostLauncherTests.cs, tests/Aspire.Cli.Tests/Commands/RunCommandTests.cs, tests/Aspire.Cli.Tests/DotNet/DotNetCliRunnerTests.cs, tests/Aspire.Cli.Tests/DotNet/ProcessInvocationOptionsTests.cs, tests/Aspire.Cli.Tests/Projects/DotNetAppHostProjectTests.cs, tests/Aspire.Cli.Tests/Projects/GuestAppHostProjectTests.cs, tests/Aspire.Cli.Tests/Templating/DotNetTemplateFactoryTests.cs, tests/Aspire.Cli.Tests/TestServices/FakeAppHostServerSession.cs, tests/Aspire.Cli.Tests/TestServices/TestAppHostStopper.cs, tests/Aspire.Cli.Tests/TestServices/TestDotNetCliRunner.cs, tests/Aspire.Cli.Tests/TestServices/TestExtensionInteractionService.cs
• affected project Aspire.Cli
polyglot affected project Aspire.Cli
typescript-api-compat affected project Aspire.Cli

Selection computed for commit d979c7e.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reviewed the timeout lifecycle changes and regression coverage; no actionable issues found.

@ellahathaway
Ella Hathaway (ellahathaway) merged commit 9cede50 into main Sep 4, 2026
171 checks passed
@ellahathaway
Ella Hathaway (ellahathaway) deleted the ellahathaway-fix-cli-startup-timeout branch September 4, 2026 15:00
@github-actions github-actions Bot added this to the 13.6 milestone Sep 4, 2026
@aspire-repo-bot

Copy link
Copy Markdown
Contributor

Pull request created: #1619

Generated by PR Documentation Check · auto · 34.2 AIC · ⌖ 7.21 AIC · ⊞ 19.7K

@aspire-repo-bot

Copy link
Copy Markdown
Contributor

📝 Documentation has been drafted in microsoft/aspire.dev#1619 targeting release/13.6.

Updated aspire-run.mdx and aspire-start.mdx (reference/cli/commands) to clarify that ASPIRE_CLI_START_TIMEOUT now only bounds AppHost startup time, not restore/build time (including safety builds for --no-build), matching the source PR's behavior change and its $env:ASPIRE_CLI_START_TIMEOUT = "15" / aspire start --no-build example.

Note

This draft PR needs human review before merging.

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

⚠️ CI Failure Analysis: Possible Flaky Test(s)

The CI build failed due to test failure(s) that appear unrelated to the PR changes. These may be flaky tests.

Suspected flaky test(s):

  • Aspire.Hosting.Radius.Tests.Secrets.SealedSecretApplyStepTests.WaitForSealedSecretSynced_StatusMatchesButSecretAbsent_KeepsWaitingThenTimesOut in job Tests / No-package tests (regular, Aspire.Hosting.Radius.Tests, Hosting.Radius, Hosting.Radius, tests/Asp... / Hosting.Radius (windows-latest)
    • Error: Assert.True() Failure
      Expected: True
      Actual: False
    • Stack Trace (first frames):
      at Aspire.Hosting.Radius.Tests.Secrets.SealedSecretApplyStepTests.WaitForSealedSecretSynced_StatusMatchesButSecretAbsent_KeepsWaitingThenTimesOut() in D:\a\aspire\aspire\tests\Aspire.Hosting.Radius.Tests\Secrets\SealedSecretApplyStepTests.cs:line 513
      
    • Why likely flaky: Matches prior recurring cause hosting-radius-sealedsecretapply-timeout-flaky (3 prior occurrences); PR changes do not touch Aspire.Hosting.Radius test code, timing-sensitive wait/timeout assertion on Windows runner.

Suggested actions:

  • Re-run the failed CI jobs to confirm if the failure is intermittent
  • If the test continues to fail, consider quarantining it using /quarantine-test <test name> <issue URL>
  • Search existing issues to see if this test is already known to be flaky

You can re-run the failed jobs from the workflow run page.

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.

Long AppHost restores and builds should not consume ASPIRE_CLI_START_TIMEOUT

4 participants