Error when running dotnet test: The JSON-RPC connection with the remote party was lost before the request could complete.
- Dominant language
- C#
- Stars
- 6.3k
- Forks
- 991
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 196
Description
### Is there an existing issue for this?
- [x] I have searched the existing issues
### Describe the bug
I am getting this error when I run tests using dotnet test inside VS Code. It seems the Aspire extension is not disconnecting cleanly when the AppHost shuts down at the end of the test.
### Expected Behavior
_No response_
### Steps To Reproduce
```
net10.0
latest
enable
enable
true
```
```
using Aspire.Hosting.Testing;
[TestClass]
public class AspireBugTests
{
[TestMethod]
public async Task AspireBugTests_1()
{
var builder = DistributedApplicationTestingBuilder.Create();
await using var application = await builder.BuildAsync();
await application.StartAsync();
await application.StopAsync();
}
}
```
### Exceptions (if any)
https://gist.github.com/duckblaster/e38baabb0c1a60b3c2686efe30608dd1
```
[2026-09-16 00:47:14.682] [DBUG] [AppHostCliBackchannel] Backchannel disconnected: RemotePartyTerminated
[2026-09-16 00:47:14.683] [FAIL] [AspireCliTelemetry] An unexpected error occurred: The JSON-RPC connection with the remote party was lost before the request could complete.
StreamJsonRpc.ConnectionLostException: The JSON-RPC connection with the remote party was lost before the request could complete.
---> System.OperationCanceledException: The operation was canceled.
at System.Threading.CancellationToken.ThrowOperationCanceledException() + 0x30
at StreamJsonRpc.MessageHandlerBase.d__23.MoveNext() + 0x4a4
--- End of stack trace from previous location ---
at StreamJsonRpc.JsonRpc.d__165.MoveNext() + 0x3af
--- End of stack trace from previous location ---
at StreamJsonRpc.JsonRpc.d__170.MoveNext() + 0x1e5
--- End of inner exception stack trace ---
at StreamJsonRpc.JsonRpc.d__170.MoveNext() + 0xda4
--- End of stack trace from previous location ---
at StreamJsonRpc.JsonRpc.d__159`1.MoveNext() + 0x74
--- End of stack trace from previous location ---
at StreamJsonRpc.Reflection.MessageFormatterEnumerableTracker.AsyncEnumerableProxy`1.AsyncEnumeratorProxy.d__11.MoveNext() + 0x7d
--- End of stack trace from previous location ---
at Aspire.Cli.Backchannel.ProfilingJsonRpcExtensions.d__4`1.MoveNext() + 0x63f
--- End of stack trace from previous location ---
at Aspire.Cli.Backchannel.AppHostCliBackchannel.d__22`1.MoveNext() + 0x217
--- End of stack trace from previous location ---
at Aspire.Cli.Backchannel.AppHostCliBackchannel.d__22`1.MoveNext() + 0x424
--- End of stack trace from previous location ---
at Aspire.Cli.Backchannel.AppHostCliBackchannel.d__20`1.MoveNext() + 0x897
--- End of stack trace from previous location ---
at Aspire.Cli.Backchannel.AppHostCliBackchannel.d__20`1.MoveNext() + 0xd39
--- End of stack trace from previous location ---
at Aspire.Cli.Commands.RunCommand.<>c__DisplayClass29_0.<b__2>d.MoveNext() + 0x188
--- End of stack trace from previous location ---
at Aspire.Cli.Commands.RunCommand.<>c__DisplayClass29_0.<b__2>d.MoveNext() + 0x3fa
--- End of stack trace from previous location ---
at Aspire.Cli.Interaction.ConsoleInteractionService.<>c__DisplayClass52_0.<b__0>d.MoveNext() + 0x59
--- End of stack trace from previous location ---
at Spectre.Console.LiveDisplay.<>c__DisplayClass17_0.<b__0>d.MoveNext() + 0x6a
--- End of stack trace from previous location ---
at Spectre.Console.LiveDisplay.<>c__DisplayClass18_0`1.<b__0>d.MoveNext() + 0x19f
--- End of stack trace from previous location ---
at Spectre.Console.DefaultExclusivityMode.d__3`1.MoveNext() + 0x167
--- End of stack trace from previous location ---
at Spectre.Console.LiveDisplay.d__18`1.MoveNext() + 0x6f
--- End of stack trace from previous location ---
at Spectre.Console.LiveDisplay.d__17.MoveNext() + 0x60
--- End of stack trace from previous location ---
at Aspire.Cli.Interaction.ConsoleInteractionService.d__52.MoveNext() + 0x5f
--- End of stack trace from previous location ---
at Aspire.Cli.Commands.RunCommand.d__29.MoveNext() + 0x18f1
--- End of stack trace from previous location ---
at Aspire.Cli.Commands.RunCommand.d__29.MoveNext() + 0x2049
```
### Aspire doctor output
```plain
Aspire Environment Check
========================
Aspire
✅ Aspire CLI version 13.5.4 (channel: stable)
✅ Developer Control Plane (DCP) connection health checks succeeded
AppHost
✅ AppHost version 13.5.3 (AspireBugTests.csproj)
.NET SDK
✅ .NET 10.0.400 installed (x64)
Container Runtime
✅ Docker: running (auto-detected (default)) ← active
Environment
✅ Operating system: Linux Ubuntu 24.04
✅ WSL2 environment detected
Details:
If you experience container connectivity issues, ensure Docker Desktop WSL integration is enabled.
✅ HTTPS development certificate is trusted
⚠️ certutil is not available; browser certificate trust may be incomplete
Install certutil from your distribution's NSS tools package (for example, libnss3-tools).
See: https://aka.ms/aspire-prerequisites#dev-certs
Details:
Aspire uses certutil to query and update NSS certificate databases used by Firefox and Chromium browsers on Linux.
Development Tools
✅ Aspire extension for VS Code is installed
Summary: 9 passed, 1 warnings, 0 failed
For detailed prerequisites: https://aka.ms/aspire-prerequisites
Aspire CLI Installations
========================
╭─────────────────────────────────┬─────────────────────────────────────────────────┬─────────┬───────────┬─────────────╮
│ Path │ Version │ Channel │ Route │ PATH status │
├─────────────────────────────────┼─────────────────────────────────────────────────┼─────────┼───────────┼─────────────┤
│ /usr/local/bin/aspire (current) │ 13.5.4+9c1b401dd67746739044f68959cbf4d3d7af93a6 │ stable │ (unknown) │ active │
╰─────────────────────────────────┴─────────────────────────────────────────────────┴─────────┴───────────┴─────────────╯
```
### Anything else?
_No response_
Contributor guide
Research direction
Start with the AppHostCliBackchannel and RunCommand stack-trace entries, then reproduce the failure with the provided MSTest project and AspireBugTests test. Trace shutdown and JSON-RPC backchannel disposal after application.StopAsync(); done means dotnet test completes without the ConnectionLostException while preserving clean AppHost shutdown.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, vscode
- Domain
- cli, devtools, testing-qa
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100