Skip to content

Fix PartDiscovery.CreatePartsAsync cancellation handling to properly throw OperationCanceledException#621

Merged
AArnott merged 5 commits intomainfrom
copilot/fix-620
Sep 11, 2025
Merged

Fix PartDiscovery.CreatePartsAsync cancellation handling to properly throw OperationCanceledException#621
AArnott merged 5 commits intomainfrom
copilot/fix-620

Conversation

Copy link
Contributor

Copilot AI commented Sep 10, 2025

  • Implement cancellation handling for PartDiscovery.CreatePartsAsync methods
  • Address code review feedback:
    • Remove cancellation token from Task.Run calls to prevent hanging
    • Simplify test setup using new CancellationToken(canceled: true)
    • Remove unstable timeout test
    • Fix StyleCop warning about multiple blank lines

Changes Made

Original Implementation

  • Added proper cancellation handling to all CreatePartsAsync methods
  • Added cancellation token to dataflow blocks and async operations
  • Added comprehensive tests for cancellation scenarios

Code Review Fixes

  1. Fixed Task.Run cancellation handling: Removed cancellationToken parameter from both Task.Run calls in CreateDiscoveryBlockChain and CreateAssemblyDiscoveryBlockChain methods to prevent hanging the TaskCompletionSource
  2. Simplified test setup: Replaced CancellationTokenSource with direct CancellationToken token = new(canceled: true) construction for cleaner test code
  3. Removed unstable test: Eliminated the timeout-based cancellation test that was prone to flakiness
  4. Fixed StyleCop warnings: Removed extra blank lines to comply with SA1507

All tests are passing and the build succeeds without warnings. The implementation now correctly handles cancellation tokens while avoiding the Task.Run hanging issue identified in code review.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI changed the title [WIP] PartDiscovery.CreatePartsAsync should throw OperationCanceledException when its cancellationToken parameter is canceled Fix PartDiscovery.CreatePartsAsync cancellation handling to properly throw OperationCanceledException Sep 10, 2025
Copilot AI requested a review from AArnott September 10, 2025 23:17
Copy link
Member

@AArnott AArnott left a comment

Choose a reason for hiding this comment

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

@copilot, please make the suggested changes.

…plify test setup, and remove unstable test

Co-authored-by: AArnott <[email protected]>
Copy link
Contributor Author

Copilot AI commented Sep 11, 2025

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:

  • 2wrvsblobprodwus2180.vsblob.vsassets.io
    • Triggering command: dotnet build -c Debug (dns block)
  • 31bvsblobprodwus2143.vsblob.vsassets.io
    • Triggering command: dotnet build -c Debug (dns block)
  • 6yfvsblobprodwus2121.vsblob.vsassets.io
    • Triggering command: dotnet build -c Debug (dns block)
  • 78kvsblobprodwus2152.vsblob.vsassets.io
    • Triggering command: dotnet build -c Debug (dns block)
  • 8wdvsblobprodwus2137.vsblob.vsassets.io
    • Triggering command: dotnet build -c Debug (dns block)
  • abcvsblobprodwus2161.vsblob.vsassets.io
    • Triggering command: dotnet build -c Debug (dns block)
  • isvvsblobprodwus2147.vsblob.vsassets.io
    • Triggering command: dotnet build -c Debug (dns block)
  • kafvsblobprodwus2165.vsblob.vsassets.io
    • Triggering command: dotnet build -c Debug (dns block)
  • km4vsblobprodwus2183.vsblob.vsassets.io
    • Triggering command: dotnet build -c Debug (dns block)
  • nypvsblobprodwus2178.vsblob.vsassets.io
    • Triggering command: dotnet build -c Debug (dns block)
  • ox9vsblobprodwus2149.vsblob.vsassets.io
    • Triggering command: dotnet build -c Debug (dns block)
  • s8nvsblobprodwus2158.vsblob.vsassets.io
    • Triggering command: dotnet build -c Debug (dns block)
  • wztvsblobprodwus2155.vsblob.vsassets.io
    • Triggering command: dotnet build -c Debug (dns block)
  • x0dvsblobprodwus2111.vsblob.vsassets.io
    • Triggering command: dotnet build -c Debug (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@AArnott AArnott marked this pull request as ready for review September 11, 2025 01:03
@AArnott AArnott enabled auto-merge (squash) September 11, 2025 01:04
@AArnott
Copy link
Member

AArnott commented Sep 11, 2025

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@AArnott
Copy link
Member

AArnott commented Sep 11, 2025

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@AArnott AArnott merged commit d4155a6 into main Sep 11, 2025
9 checks passed
@AArnott AArnott deleted the copilot/fix-620 branch September 11, 2025 22:51
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.

PartDiscovery.CreatePartsAsync should throw OperationCanceledException when its cancellationToken parameter is canceled

3 participants