You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
↑ Each review finding has a focused test; the new CLI tests were confirmed to fail with their fixes reverted. ↑ Stop, backchannel, tray-protocol and graceful-shutdown and terminal test classes pass (181 CLI), plus orchestrator (67) and focused hosting stop tests (7). ↓ Concurrent waiters are covered with a test executor and a single CLI caller against a live child process, not two real aspire stop --wait clients against real DCP. ↓ CI has not finished on the latest commit.
Diagnosis confidence
9/10
↑ Each failure mode is traceable in the code: per-caller finally stop, first-wins exit code, StreamJsonRpc awaiting the reply after $/cancelRequest, and the escalating stop that followed a timed-out or uncertain-delivery wait.
Evidence fit
8/10
↑ The fixes address exactly the review findings. ↓ None was reported from a user-observed failure; they are code-review findings.
Description
Follow-up to #22583 (aspire stop --wait), addressing the four review comments left open after it merged. All are correctness or clarity fixes to the new option; default aspire stop behavior is unchanged.
Concurrent stop --wait requests no longer interrupt each other. Each request used to schedule the AppHost stop when it finished. A second request hit the executor's one-shot stop guard, got false right away, and stopped the AppHost, closing the first caller's connection before it got its result. ApplicationOrchestrator now shares one in-progress cleanup across waiters, cancels it only when the last waiter gives up, and schedules the AppHost stop once, when the cleanup completes. The AppHost still always stops.
--timeout is enforced on the client side. Canceling a StreamJsonRpc call only sends $/cancelRequest and keeps awaiting the reply, so an AppHost that never replied could hang stop --wait, including --all and --force. The CLI now stops waiting as soon as the deadline passes. A late "not confirmed" reply caused by the deadline's cancellation is reported as a timeout (exit 17), not exit 2.
A timed-out wait does not stop the AppHost out from under another waiter. After the deadline passes, the CLI only watches for the AppHost to exit; it no longer sends SIGTERM, signals the launcher, or force-kills it. If the AppHost stays up because another stop --wait is still waiting on the shared cleanup, the CLI leaves it running, keeps its socket, reports the timeout and that the AppHost was left running, and exits with code 2 so --force skips persistent cleanup and --all reports failure.
An uncertain teardown request is also observe-only. If the teardown request fails in a way that does not prove it never reached the AppHost (for example the connection drops while the request is in flight), the CLI treats it like a timeout: it does not signal the AppHost or resend the stop, and leaves it running with exit 2 if it does not exit. Only a request that provably was never sent (unusable connection, or an AppHost without the method) still escalates to the regular stop.
stop --all --wait exit code is deterministic. It used to be whichever AppHost reported its failure first. Failures are now aggregated by precedence: unconfirmed (2) > timeout (17) > unsupported AppHost (9).
Docs and messages are scoped to non-persistent resources. Normal DCP cleanup intentionally keeps persistent containers. The --wait help, the progress and success messages, and the CLI README now say "non-persistent resources" and explain that --force removes persistent ones after the AppHost stops.
User-facing usage
--wait Wait until the AppHost's non-persistent resources, such as containers, are torn down before returning. Persistent resources are kept unless --force is also specified
Waiting for the non-persistent resources of apphost.cs to be torn down...
✅ apphost.cs stopped successfully.
✅ The non-persistent resources of apphost.cs were torn down.
Validation
dotnet test --project tests/Aspire.Cli.Tests/Aspire.Cli.Tests.csproj --no-launch-profile -- --filter-class "*.StopCommandTests" --filter-class "*.AppHostAuxiliaryBackchannelTests" --filter-class "*.TrayProtocolCommandTests" --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true": passed at the time (134/134); after the timed-out-wait change, the same run plus *.ProcessTreeGracefulShutdownServiceTests passes; with the uncertain-delivery change and *.TerminalCommandTests added, 181/181, including StopCommand_Wait_LeavesAppHostRunningWhenTimedOutTeardownContinuesForAnotherCaller (a real child process must stay alive) and StopCommand_Wait_ReportsTimeoutWhenAppHostRepliesNotConfirmedAfterDeadline.
New StopCommand_AllWait_ExitCodeDoesNotDependOnTeardownCompletionOrder (both completion orders) and StopAppHostAndWaitForResourceCleanupAsync_WhenAppHostWithholdsResponse_StopsWaitingWhenCanceled (a real JSON-RPC transport whose AppHost never replies). Both fail with the source fixes reverted.
New tests cover two waiters with the cleanup held open (one executor cleanup, completion callback runs once) and waiters canceling one after the other (the cleanup is canceled only by the last one).
dotnet test --project tests/Aspire.Hosting.Tests/Aspire.Hosting.Tests.csproj --no-launch-profile -- --filter-method "*.StopAsyncWithResourceCleanupReportsCleanupAndStopsAppHost" --filter-method "*.StopAndWaitForResourceCleanupAsync*" --filter-method "*.StopAppHostAsyncInitiatesShutdown" --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true": passed (7/7), including the end-to-end RPC test against real DCP.
dotnet build tests/Aspire.Cli.EndToEnd.Tests/Aspire.Cli.EndToEnd.Tests.csproj: 0 warnings, 0 errors. The Docker E2E (StopWaitTests) was not run locally.
- Share one in-progress resource cleanup across concurrent stop --wait
requests and schedule the AppHost stop once, when that cleanup completes,
so one caller cannot close another caller's connection.
- Enforce the --timeout deadline on the client await: StreamJsonRpc
cancellation only sends $/cancelRequest, so stop waiting as soon as the
token is canceled, and report a canceled AppHost reply as a timeout.
- Aggregate stop --all --wait teardown failures with a deterministic
precedence (unconfirmed > timeout > unsupported).
- Scope --wait docs and messages to non-persistent resources and explain
how --force removes persistent ones.
Co-authored-by: Copilot App <[email protected]>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
A critical timeout-path race can stop the AppHost and disconnect another cleanup waiter, and the late-false-reply timeout branch lacks regression coverage.
Concurrent stop --wait callers share one AppHost cleanup, so after this
caller's wait times out the AppHost may legitimately stay up for another
caller. Only observe the process instead of signaling or killing it, keep
it running and report exit 2 when it does not exit, and cover the late
not-confirmed reply being reported as a timeout.
Co-authored-by: Copilot App <[email protected]>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
A disconnect after an accepted teardown request can trigger fallback termination of the AppHost before shared cleanup completes, and a cancellation race can leave RPC task exceptions unobserved.
The RPC task can fault after WaitAsync cancellation wins but before this catch filter runs. Then IsCompleted is true, the catch is skipped, and the abandoned task's exception is not observed. Call the existing ObserveFaults helper on every cancellation; it handles both pending and already-faulted tasks.
A failed teardown request now escalates to the regular stop only when it
provably never reached the AppHost. Other failures may have started a
cleanup shared with other waiters, so the AppHost is only observed and
left running if it does not exit.
Co-authored-by: Copilot App <[email protected]>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
The regular stop path still immediately signals the AppHost for TornDown and NotConfirmed outcomes, risking disconnection of another caller’s pending RPC response and a false unconfirmed-teardown result.
No open issues 🎉
1 previously missed issue
In code that hasn't changed since last review
Avoid signaling AppHost while other teardown RPCs are pending
src/Aspire.Cli/Commands/StopCommand.cs:705
For TornDown and NotConfirmed, the regular stop path still signals the AppHost immediately, bypassing its scheduled shutdown delay while another waiter's RPC response may still be pending. The first caller to receive a response can therefore disconnect another caller, making it report unconfirmed teardown even when cleanup succeeded. Use the observe-only path for these outcomes too, and add coverage with two callers whose responses arrive at different times.
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
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.
Agent assessment
Self-reported assessment, not an independent review.
Assessed revision:
e45e30b97ceb8185a6366f79a14e2ce21f81a7f4↑ Stop, backchannel, tray-protocol and graceful-shutdown and terminal test classes pass (181 CLI), plus orchestrator (67) and focused hosting stop tests (7).
↓ Concurrent waiters are covered with a test executor and a single CLI caller against a live child process, not two real
aspire stop --waitclients against real DCP.↓ CI has not finished on the latest commit.
finallystop, first-wins exit code, StreamJsonRpc awaiting the reply after$/cancelRequest, and the escalating stop that followed a timed-out or uncertain-delivery wait.↓ None was reported from a user-observed failure; they are code-review findings.
Description
Follow-up to #22583 (
aspire stop --wait), addressing the four review comments left open after it merged. All are correctness or clarity fixes to the new option; defaultaspire stopbehavior is unchanged.stop --waitrequests no longer interrupt each other. Each request used to schedule the AppHost stop when it finished. A second request hit the executor's one-shot stop guard, gotfalseright away, and stopped the AppHost, closing the first caller's connection before it got its result.ApplicationOrchestratornow shares one in-progress cleanup across waiters, cancels it only when the last waiter gives up, and schedules the AppHost stop once, when the cleanup completes. The AppHost still always stops.--timeoutis enforced on the client side. Canceling a StreamJsonRpc call only sends$/cancelRequestand keeps awaiting the reply, so an AppHost that never replied could hangstop --wait, including--alland--force. The CLI now stops waiting as soon as the deadline passes. A late "not confirmed" reply caused by the deadline's cancellation is reported as a timeout (exit 17), not exit 2.stop --waitis still waiting on the shared cleanup, the CLI leaves it running, keeps its socket, reports the timeout and that the AppHost was left running, and exits with code 2 so--forceskips persistent cleanup and--allreports failure.stop --all --waitexit code is deterministic. It used to be whichever AppHost reported its failure first. Failures are now aggregated by precedence: unconfirmed (2) > timeout (17) > unsupported AppHost (9).--waithelp, the progress and success messages, and the CLI README now say "non-persistent resources" and explain that--forceremoves persistent ones after the AppHost stops.User-facing usage
Validation
dotnet test --project tests/Aspire.Cli.Tests/Aspire.Cli.Tests.csproj --no-launch-profile -- --filter-class "*.StopCommandTests" --filter-class "*.AppHostAuxiliaryBackchannelTests" --filter-class "*.TrayProtocolCommandTests" --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true": passed at the time (134/134); after the timed-out-wait change, the same run plus*.ProcessTreeGracefulShutdownServiceTestspasses; with the uncertain-delivery change and*.TerminalCommandTestsadded, 181/181, includingStopCommand_Wait_LeavesAppHostRunningWhenTimedOutTeardownContinuesForAnotherCaller(a real child process must stay alive) andStopCommand_Wait_ReportsTimeoutWhenAppHostRepliesNotConfirmedAfterDeadline.StopCommand_AllWait_ExitCodeDoesNotDependOnTeardownCompletionOrder(both completion orders) andStopAppHostAndWaitForResourceCleanupAsync_WhenAppHostWithholdsResponse_StopsWaitingWhenCanceled(a real JSON-RPC transport whose AppHost never replies). Both fail with the source fixes reverted.dotnet test --project tests/Aspire.Hosting.Tests/Aspire.Hosting.Tests.csproj --no-launch-profile -- --filter-class "*.ApplicationOrchestratorTests" --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true": passed (67/67).dotnet test --project tests/Aspire.Hosting.Tests/Aspire.Hosting.Tests.csproj --no-launch-profile -- --filter-method "*.StopAsyncWithResourceCleanupReportsCleanupAndStopsAppHost" --filter-method "*.StopAndWaitForResourceCleanupAsync*" --filter-method "*.StopAppHostAsyncInitiatesShutdown" --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true": passed (7/7), including the end-to-end RPC test against real DCP.dotnet build tests/Aspire.Cli.EndToEnd.Tests/Aspire.Cli.EndToEnd.Tests.csproj: 0 warnings, 0 errors. The Docker E2E (StopWaitTests) was not run locally.Relates to #22510, #22511
Checklist
<remarks />and<code />elements on your triple slash comments?