Shorten backchannel socket paths#17226
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 17226Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 17226" |
|
I'm interested how you make this compatible in both directions. e.g. old CLI vs new app host. Does the app host listen on multiple files? Also, if introducing a new backchannel format, it would be a good opportunity to make the path hash case insensitive, e.g. on windows convert the path to lower before calculating the hash. I kind of improved it here by making the drive letter consistent. But it would be better if the whole path was case insensitive to avoid related issues. |
I don't. This was discussed at the team meeting yesterday. The approach with this PR is that a new CLI can discover backchannel socket created by older app host, but the old CLI cannot work with newer app host that is using the new backchannel path--you have to upgrade your CLI to make things work. I could not think of a good way to solve the latter use case; I am open to suggestions.
You mean do this on Windows only? I can look into that. |
cf0a045 to
c8c6397
Compare
|
Should be ready for review now but need to do some more manual testing because AI testing produced ambiguous results. |
There was a problem hiding this comment.
Pull request overview
This PR updates Aspire’s backchannel socket location and naming to reduce the risk of exceeding Unix domain socket path byte limits (notably with long / non-ASCII home directories), while keeping compatibility with older AppHost/CLI versions.
Changes:
- Introduces a compact socket directory (
~/.aspire/cli/bch/) and compact socket filename format using base64url identifiers plus PID. - Adds shared helpers to compute/validate socket paths by UTF-8 byte length (including trailing null) and to discover both compact + legacy sockets.
- Updates CLI monitoring/discovery and test coverage to account for compact + legacy socket locations/formats.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Aspire.Hosting.Tests/Utils/UnixSocketHelper.cs | Updates test helper to use shared compact CLI socket path computation. |
| tests/Aspire.Hosting.Tests/Backchannel/AuxiliaryBackchannelTests.cs | Adjusts assertions to the compact socket filename + directory and validates byte-length limit. |
| tests/Aspire.Cli.Tests/Utils/CliPathHelperTests.cs | Updates CLI socket-path tests to expect the new compact directory and compact names. |
| tests/Aspire.Cli.Tests/Utils/AppHostHelperTests.cs | Updates CLI helper tests for compact IDs, legacy discovery, and UTF-8 byte-limit regression coverage. |
| src/Shared/BackchannelConstants.cs | Implements compact IDs/paths, legacy fallback discovery, and byte-length validation helpers shared by AppHost + CLI. |
| src/Aspire.Hosting/Backchannel/AuxiliaryBackchannelService.cs | Updates orphan cleanup and fallback naming to use compact AppHost IDs and legacy cleanup. |
| src/Aspire.Cli/Utils/CliPathHelper.cs | Switches CLI socket creation to use shared compact CLI socket path logic. |
| src/Aspire.Cli/Utils/AppHostHelper.cs | Updates helper docs and adds legacy-hash enumeration wrapper. |
| src/Aspire.Cli/Commands/AppHostLauncher.cs | Extends detached launch discovery to search multiple legacy hashes. |
| src/Aspire.Cli/Backchannel/AuxiliaryBackchannelMonitor.cs | Watches both compact + legacy directories and updates scan logic to handle compact formats. |
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/aspire/sessions/b36250b0-fec3-464b-b778-2dafbf270f00 Co-authored-by: karolz-ms <15271049+karolz-ms@users.noreply.github.com>
efee6ac to
40ee29b
Compare
|
Manual and agentic testing complete, all good now |
|
❓ CLI E2E Tests unknown — 94 passed, 0 failed, 2 unknown (commit View all recordings
📹 Recordings uploaded automatically from CI run #26174406587 |
Description
Fixes #15752
Users with long or non-ASCII home directory paths can exceed the byte-based Unix domain socket path limits when Aspire creates backchannel sockets. This shortens the backchannel socket location and file names so AppHost/CLI communication has more path budget while preserving the visible process ID for debugging.
User-facing usage
No new CLI syntax is required. Existing
aspire runand MCP workflows use shorter backchannel socket paths under~/.aspire/cli/bch/, and the CLI still discovers legacy sockets under~/.aspire/cli/backchannels/when connecting to AppHosts built with older libraries.Implementation details
Validation
dotnet build tests\Aspire.Cli.Tests\Aspire.Cli.Tests.csproj --no-restore /p:SkipNativeBuild=truedotnet build tests\Aspire.Hosting.Tests\Aspire.Hosting.Tests.csproj --no-restore /p:SkipNativeBuild=truedotnet test --project tests\Aspire.Cli.Tests\Aspire.Cli.Tests.csproj --no-launch-profile -- --filter-class "*.AppHostHelperTests" --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true"dotnet test --project tests\Aspire.Cli.Tests\Aspire.Cli.Tests.csproj --no-launch-profile -- --filter-class "*.CliPathHelperTests" --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true"dotnet test --project tests\Aspire.Hosting.Tests\Aspire.Hosting.Tests.csproj --no-launch-profile -- --filter-method "*.SocketPathUsesCompactFormat" --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true"dotnet test --project tests\Aspire.Hosting.Tests\Aspire.Hosting.Tests.csproj --no-build --no-launch-profile -- --filter-class "*.AppHostBackchannelTests" --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true"Checklist
<remarks />and<code />elements on your triple slash comments?