Skip to content

Fix cancellation token usage to prevent ObjectDisposedException - #7088

Merged
jebriede merged 3 commits into
devfrom
dev-jebriede-FixCancellationTokensForObjectDisposed
Jan 31, 2026
Merged

jebriede merged 3 commits into
devfrom
dev-jebriede-FixCancellationTokensForObjectDisposed

Conversation

@jebriede

@jebriede jebriede commented Jan 30, 2026 •

Copy link
Copy Markdown
Contributor

Bug

Fixes: https://github.com/NuGet/Client.Engineering/issues/3499

Description

Fix ObjectDisposedException by implementing token-passing pattern

  • Add CancellationToken parameters to SetCurrentPackageAsync and status update method
  • Replace CancellationToken.None with captured tokens where applicable
  • Add proper disposal of CancellationTokenSource in PackageItemViewModel
  • Update all call sites including tests to pass tokens through async chains

This update fixes the underlying issues and follows up on the earlier PR (#6918), taking a new approach based on the suggestions from the discussion thread here: #6918 (comment).

Note: There are more instances of a cancellation token None being used and in the PackageManagerControl and other places. This PR does not attempt to fix all of those instances, but instead focuses on the localized change for the PackageItemViewModel to improve the token-passing pattern and avoid the ObjectDisposedException.

PR Checklist

  • Meaningful title, helpful description and a linked NuGet/Home issue
  • Added tests Updated tests. Manually tested quick cycling of tabs, refreshing, and searching.
  • Link to an issue or pull request to update docs if this PR changes settings, environment variables, new feature, etc.

@jebriede
jebriede requested a review from a team as a code owner January 30, 2026 00:30
@jebriede
jebriede requested review from martinrrm and zivkan January 30, 2026 00:30
zivkan
zivkan previously approved these changes Jan 30, 2026
@jebriede
jebriede enabled auto-merge (squash) January 31, 2026 02:06
@jebriede
jebriede merged commit 4bacd05 into dev Jan 31, 2026
16 checks passed
@jebriede
jebriede deleted the dev-jebriede-FixCancellationTokensForObjectDisposed branch January 31, 2026 04:15
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.

3 participants