Fix JSON-RPC error on disconnect and auto-restart Aspire debug session on AppHost restart#14548
Merged
adamint merged 3 commits intodotnet:mainfrom Feb 25, 2026
Merged
Conversation
Contributor
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 14548Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 14548" |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR enhances the Aspire VS Code extension debug session to fix JSON-RPC connection errors during disconnect and to automatically restart debug sessions when the AppHost terminates unexpectedly.
Changes:
- Added double-disposal protection with a
_disposedflag - Implemented auto-restart functionality for AppHost crashes using a
_userInitiatedStopflag to distinguish user-initiated stops from system failures - Improved error handling for
stopCli()calls by catching and logging failures gracefully
Comment on lines
+227
to
+228
| const shouldRestart = !this._userInitiatedStop; | ||
| const config = this.configuration; |
There was a problem hiding this comment.
The configuration should be captured before calling dispose() to avoid potential issues. While the configuration is captured into a local variable before dispose is called, the order of operations could be clearer. Consider capturing the configuration at the start of the if block (line 226) before any other operations.
Suggested change
| const shouldRestart = !this._userInitiatedStop; | |
| const config = this.configuration; | |
| const config = this.configuration; | |
| const shouldRestart = !this._userInitiatedStop; |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
mitchdenny
approved these changes
Feb 24, 2026
adamint
added a commit
to adamint/aspire
that referenced
this pull request
Mar 2, 2026
…n on AppHost restart (dotnet#14548) * Fix JSON-RPC error on disconnect and auto-restart debug session on AppHost restart * Update extension/src/debugger/AspireDebugSession.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update extension/src/debugger/AspireDebugSession.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
7 tasks
adamint
added a commit
that referenced
this pull request
Mar 2, 2026
* Detect CLI at default install paths when not on PATH (#14545) Check default installation directories (~/.aspire/bin, ~/.dotnet/tools) when the Aspire CLI is not found on the system PATH. If found at a default location, the VS Code setting is auto-updated. If later found on PATH, the setting is cleared. Resolution order: configured custom path > system PATH > default install paths. Fixes #14235 * Fix JSON-RPC error on disconnect and auto-restart Aspire debug session on AppHost restart (#14548) * Fix JSON-RPC error on disconnect and auto-restart debug session on AppHost restart * Update extension/src/debugger/AspireDebugSession.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update extension/src/debugger/AspireDebugSession.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes two issues in the Aspire VS Code extension debug session:
Fixed unexpected JSON-RPC connection lost error on debug session disconnect: When stopping or restarting the Aspire debug session, the CLI process is killed which closes the JSON-RPC connection. Previously this triggered an error notification to the user. Now,
stopCli()failures during dispose are caught and logged gracefully, and thedispose()method is guarded against double-disposal to prevent redundantstopClicalls.Restarting the AppHost resource now restarts the Aspire debug session: Previously, when the AppHost debug session terminated (e.g., due to a resource restart), the Aspire debug session would simply dispose without restarting. Now, if the AppHost terminates and the stop was not user-initiated (i.e., the user didn't explicitly disconnect), the Aspire debug session automatically restarts by launching a new debug session with the same configuration.
(Tested manually. The unexpected JSON-RPC connection lost error was happening on every restart before)
Changes
_disposedflag to prevent double-disposal of the debug session_userInitiatedStopflag to distinguish user-initiated stops from AppHost-initiated terminationsstopCli()call in error handler since the connection may already be closed during disposestopCli()call fromdispose()(already handled by disposables)Checklist
<remarks />and<code />elements on your triple slash comments?aspire.devissue: