Skip to content

Improve AppHost backchannel connection error message#18051

Open
mehara-rothila wants to merge 2 commits into
microsoft:mainfrom
mehara-rothila:fix-17277-apphost-connect-error
Open

Improve AppHost backchannel connection error message#18051
mehara-rothila wants to merge 2 commits into
microsoft:mainfrom
mehara-rothila:fix-17277-apphost-connect-error

Conversation

@mehara-rothila

Copy link
Copy Markdown

Fixes #17277

When the AppHost exits before the CLI can establish a backchannel connection, the error omitted the exit code and used redundant wording (possibly crashed and exited unexpectedly say the same thing). This PR includes the exit code and drops the redundant phrasing, in both the local (DotNetCliRunner) and server (GuestAppHostProject) backchannel paths.

Before:

An error occurred while connecting to the AppHost. The AppHost possibly crashed before it was available: AppHost process has exited unexpectedly

After:

An error occurred while connecting to the AppHost: The AppHost process exited unexpectedly with exit code 42.

The ErrorConnectingToAppHost resource string and its 13 .xlf files are updated (sources synced, targets flagged needs-review-translation). Built locally against .NET 10.0.201 — compiles clean and xliff is in sync.

When the AppHost process exits before the CLI can establish a backchannel
connection, the error message was vague: it omitted the exit code, repeated
itself ("possibly crashed" and "exited unexpectedly" mean the same thing),
and could end with a trailing period from both the format string and the
inner message.

Include the exit code in the message and drop the redundant "possibly
crashed before it was available" phrasing so the error clearly states what
happened. This is fixed in both the local (DotNetCliRunner) and server
(GuestAppHostProject) backchannel paths.

Before: An error occurred while connecting to the AppHost. The AppHost possibly crashed before it was available: AppHost process has exited unexpectedly
After:  An error occurred while connecting to the AppHost: The AppHost process exited unexpectedly with exit code 42.

Fixes microsoft#17277
Copilot AI review requested due to automatic review settings June 9, 2026 16:09

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

github-actions Bot commented Jun 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 -- 18051

Or

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

@mehara-rothila

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

</data>
<data name="ErrorConnectingToAppHost" xml:space="preserve">
<value>An error occurred while connecting to the AppHost. The AppHost possibly crashed before it was available: {0}</value>
<value>An error occurred while connecting to the AppHost: {0}.</value>

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.

Suggested change
<value>An error occurred while connecting to the AppHost: {0}.</value>
<value>An error occurred while connecting to the AppHost: {0}</value>

See #17288 - strings with interpolated content shouldn't end with a period.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done

var message = execution.ExitCode == CliExitCodes.Success
? "AppHost process has exited"
: "AppHost process has exited unexpectedly";
? $"The AppHost process exited with exit code {execution.ExitCode}"

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.

I don't think we need the exit code when the apphost process exited successfully.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done

var message = process.ExitCode == CliExitCodes.Success
? "AppHost server process has exited"
: "AppHost server process has exited unexpectedly";
? $"The AppHost server process exited with exit code {process.ExitCode}"

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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done

- Drop the trailing period from the ErrorConnectingToAppHost string
  (interpolated strings shouldn't end with a period)
- Omit the exit code when the AppHost exited successfully, in both the
  local (DotNetCliRunner) and server (GuestAppHostProject) paths
- Re-sync the 13 .xlf source strings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CLI error message when AppHost exits before backchannel connection is vague and missing exit code

3 participants