Skip to content

Fix flaky ResolverGather_TimeoutFromPrimaryRepositoryThrows test - #7242

Merged
jeffkl merged 1 commit into
devfrom
dtivel/fix-resolver-gather-race
Mar 31, 2026
Merged

jeffkl merged 1 commit into
devfrom
dtivel/fix-resolver-gather-race

Conversation

@dtivel

@dtivel dtivel commented Mar 29, 2026

Copy link
Copy Markdown
Contributor

Bug

Fixes: NuGet/Home#14833

Description

The test ResolverGather_TimeoutFromPrimaryRepositoryThrows asserts that a primary source timeout throws InvalidOperationException. GatherPackageAsync(...) converts OperationCanceledException to InvalidOperationException, but cancellation checks in the main loop and worker task entry can fire first under CPU contention, producing a raw OperationCanceledException that bypasses the conversion. Both exception types correctly indicate the gather operation failed.

This change accepts either InvalidOperationException or OperationCanceledException as passing.

This change also disposes CancellationTokenSource instances.

PR Checklist

  • Meaningful title, helpful description and a linked NuGet/Home issue
  • N/A [ ] Added tests
  • N/A [ ] Link to an issue or pull request to update docs if this PR changes settings, environment variables, new feature, etc.

The test asserts that a primary source timeout throws
InvalidOperationException. GatherPackageAsync converts
OperationCanceledException to InvalidOperationException, but
cancellation checks in the main loop and worker task entry can fire
first under CPU contention, producing a raw OperationCanceledException
that bypasses the conversion. Both exception types correctly indicate
the gather operation failed.

Accept either InvalidOperationException or OperationCanceledException.

Co-authored-by: Copilot <[email protected]>
@dtivel
dtivel requested a review from a team as a code owner March 29, 2026 19:35
@dtivel
dtivel requested review from donnie-msft and jebriede March 29, 2026 19:35
@jeffkl
jeffkl enabled auto-merge (squash) March 31, 2026 22:44
@jeffkl
jeffkl merged commit 9065b8f into dev Mar 31, 2026
16 checks passed
@jeffkl
jeffkl deleted the dtivel/fix-resolver-gather-race branch March 31, 2026 23:30
Copilot AI pushed a commit that referenced this pull request Apr 2, 2026
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.

Test: ResolverGather_TimeoutFromPrimaryRepositoryThrows is flaky under CPU contention

4 participants