Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 12, 2025

Description

Pressing Ctrl+C during aspire update would stall for up to 26 seconds instead of canceling immediately. The NuGetPackagePrefetcher background service was not passing the cancellation token when fetching package channels.

Fix: Pass stoppingToken to GetChannelsAsync() call in NuGetPackagePrefetcher.ExecuteAsync():

// Before:
var channels = await packagingService.GetChannelsAsync();

// After:  
var channels = await packagingService.GetChannelsAsync(stoppingToken);

This ensures cancellation propagates through the prefetcher, allowing immediate termination when the user cancels.

Fixes #6987

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?
Original prompt

This section details on the original issue you should resolve

<issue_title>aspire update does not cancel on ctrl+c</issue_title>
<issue_description>### Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

I just ran aspire update meaning to update update the aspire CLI, however.

Realising my mistake, I immediately pressed ctrl + c to try and cancel the process, however it took 26 seconds for the cli to actually stop

Image

Expected Behavior

CLI should stop almost instantly after hitting ctrl+c

Steps To Reproduce

  1. Run aspire update in a directory with lots of recursive children. (In my case was %UserProfile%).
  2. Press ctrl+c

Exceptions (if any)

No response

.NET Version info

aspire --version
9.5.0-preview.1.25460.2+b7914a785128f739a0065144c3e107947f3eef30

Anything else?

Whilst running this, OneDrive did pop up a load of notifications that it was downloading files, which may have contributed to why the process took so long to complete, although that should be somewhat irrelevant if cancellation was honoured.</issue_description>

<agent_instructions>There appears to be a cancellation bug related to aspire update and the NuGetPackage prefetcher or package cache logic where if you immediately press CTRL-C after executing aspire update it will potentially stall until it has finished fetching the list of packages from NuGet.

Analyze the codepath from the prefetcher all the way down to invoking the DotNetCliRunner to do package searches and identify if there is a location where a cancellation token may not be being passed or honoured.</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@davidfowl Can you run with --debug? It might mean we're not flowing the cancellation token properly (we recently updated System.CommandLine). @davidfowl I ran into this.

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Fix ctrl+c not canceling aspire update process Fix: Pass cancellation token to GetChannelsAsync in NuGetPackagePrefetcher Nov 12, 2025
Copilot finished work on behalf of mitchdenny November 12, 2025 02:10
Copilot AI requested a review from mitchdenny November 12, 2025 02:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

aspire update does not cancel on ctrl+c AspireRedisExtensions AddRedisClient breaks with Azure Cache for Redis

3 participants