Skip to content

Show AppHost debug start errors in console#16516

Closed
adamint wants to merge 2 commits intomicrosoft:mainfrom
adamint:dev/adamint/issue15578-vscode-debug-failures
Closed

Show AppHost debug start errors in console#16516
adamint wants to merge 2 commits intomicrosoft:mainfrom
adamint:dev/adamint/issue15578-vscode-debug-failures

Conversation

@adamint
Copy link
Copy Markdown
Member

@adamint adamint commented Apr 28, 2026

Description

Fixes #15578

When a VS Code AppHost debug launch fails before the child debug session starts, the extension now writes the failure details to the Debug Console as stderr before showing the existing error dialog.

Validation:

  • npm run compile-tests && npm run unit-test -- --grep "Dotnet Debugger Extension Tests" --timeout 10000

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
  • Does the change require an update in our Aspire docs?

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 28, 2026 07:23
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 28, 2026

🚀 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 -- 16516

Or

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

Copy link
Copy Markdown
Contributor

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 improves the VS Code Aspire debugging experience by ensuring AppHost debug-launch failures that occur before the child debug session starts are surfaced directly in the Debug Console (as stderr), in addition to the existing error dialog—addressing #15578.

Changes:

  • Emit AppHost start failures to the Debug Console as stderr output before showing the error dialog.
  • Extend sendMessageWithEmoji to support an explicit output category (stdout/stderr).
  • Add a unit test validating that a failed AppHost start produces a Debug Console stderr output event.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
extension/src/debugger/AspireDebugSession.ts Writes AppHost start errors to Debug Console as stderr; extends message helper to support output category.
extension/src/test/dotnetDebugger.test.ts Adds coverage to assert failed AppHost start emits a stderr Debug Console output event and shows the error dialog.

Comment on lines +509 to 511
sendMessageWithEmoji(emoji: string, message: string, addNewLine: boolean = true, category: 'stdout' | 'stderr' = 'stdout') {
this.sendMessage(`${emoji} ${message}`, addNewLine, category);
}
Copy link

Copilot AI Apr 28, 2026

Choose a reason for hiding this comment

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

Now that sendMessageWithEmoji accepts an output category, some existing stderr paths still call it without specifying stderr (e.g., spawnAspireCommand's stderrCallback uses sendMessageWithEmoji("❌", line, false)), which will keep emitting those error lines as stdout. Update those call sites to pass category: 'stderr' so CLI/AppHost error output renders and filters correctly in the Debug Console.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in a0936f9. The spawnAspireCommand stderr callback now sends output with the stderr category.

Comment on lines +319 to +321
const errorMessage = String(err);
extensionLogOutputChannel.error(`Error starting AppHost debug session: ${errorMessage}`);
this.sendMessageWithEmoji("❌", errorMessage, true, 'stderr');
Copy link

Copilot AI Apr 28, 2026

Choose a reason for hiding this comment

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

The catch block converts the thrown value to String(err) and sends only that single-line message to the Debug Console. For Error instances this typically drops the stack trace, which can be the most useful “failure details” when AppHost startup fails. Consider emitting err.stack (or an equivalent richer formatting) when available so users get actionable diagnostics.

Suggested change
const errorMessage = String(err);
extensionLogOutputChannel.error(`Error starting AppHost debug session: ${errorMessage}`);
this.sendMessageWithEmoji("❌", errorMessage, true, 'stderr');
const errorMessage = err instanceof Error ? err.message : String(err);
const errorDetails = err instanceof Error ? (err.stack ?? err.message) : String(err);
extensionLogOutputChannel.error(`Error starting AppHost debug session: ${errorDetails}`);
this.sendMessageWithEmoji("❌", errorDetails, true, 'stderr');

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in a0936f9. Error instances now emit stack/details to the Debug Console while the user-facing error dialog keeps the short message.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

VS Code - Debug doesn't work if app host fails before build

2 participants