Show AppHost debug start errors in console#16516
Show AppHost debug start errors in console#16516adamint wants to merge 2 commits intomicrosoft:mainfrom
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 16516Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 16516" |
There was a problem hiding this comment.
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
stderroutput before showing the error dialog. - Extend
sendMessageWithEmojito support an explicit output category (stdout/stderr). - Add a unit test validating that a failed AppHost start produces a Debug Console
stderroutput 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. |
| sendMessageWithEmoji(emoji: string, message: string, addNewLine: boolean = true, category: 'stdout' | 'stderr' = 'stdout') { | ||
| this.sendMessage(`${emoji} ${message}`, addNewLine, category); | ||
| } |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Fixed in a0936f9. The spawnAspireCommand stderr callback now sends output with the stderr category.
| const errorMessage = String(err); | ||
| extensionLogOutputChannel.error(`Error starting AppHost debug session: ${errorMessage}`); | ||
| this.sendMessageWithEmoji("❌", errorMessage, true, 'stderr'); |
There was a problem hiding this comment.
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.
| 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'); |
There was a problem hiding this comment.
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>
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 10000Checklist
<remarks />and<code />elements on your triple slash comments?aspire.devissue: