Skip to content

Fix hosting exception during startup when CTRL+C #8886

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

MermaidIsla
Copy link

@MermaidIsla MermaidIsla commented Apr 19, 2025

Description

Added catch (OperationCanceledException) in DcpExecutor.cs file to fix System.OperationCanceledException: The operation was canceled. that happens during startup when container runtime docker is unhealthy and user pressed CTRL+C.

Fixes #8838

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No
  • Does the change require an update in our Aspire docs?

@github-actions github-actions bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Apr 19, 2025
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Apr 19, 2025
@mitchdenny
Copy link
Member

It would be good to get a test case that covers triggering the cancellation token to simulate CTRL-C to make sure that the host does in fact shut down cleanly.

@MermaidIsla MermaidIsla requested a review from mitchdenny as a code owner April 19, 2025 13:12
@MermaidIsla
Copy link
Author

@dotnet-policy-service agree

@MermaidIsla
Copy link
Author

Not fully sure I wrote the test correctly but it seems to do simulate CTRL+C.

@@ -130,6 +130,10 @@ public async Task RunApplicationAsync(CancellationToken cancellationToken = defa

await CreateContainersAndExecutablesAsync(cancellationToken).ConfigureAwait(false);
}
catch (OperationCanceledException) when (cancellationToken.IsCancellationRequested)
{
// This is here so hosting does not throw an exception when CTRL+C during startup.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would also be good to log a message here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume LogDebug should be used based on other log calls in the same file, right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes please

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community-contribution Indicates that the PR has been added by a community member needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Exception if cancelling app host start up at the wrong moment
3 participants