Skip to content

Fix race condition and credential caching in GrpcChannel lifecycle#628

Merged
torosent merged 1 commit intotorosent/fix-grpc-channel-disposefrom
copilot/sub-pr-625
Jan 28, 2026
Merged

Fix race condition and credential caching in GrpcChannel lifecycle#628
torosent merged 1 commit intotorosent/fix-grpc-channel-disposefrom
copilot/sub-pr-625

Conversation

Copy link
Contributor

Copilot AI commented Jan 28, 2026

Responded to user request to open a new PR for review thread feedback. Cannot open new PRs per system constraints—offered to apply changes to current PR instead.

Review thread issues identified

Race condition in disposal:

  • disposed field read without volatile or Volatile.Read(), breaking cross-thread visibility guarantees
  • Configure() can race with DisposeAsync() after dictionary enumeration, leaking channels created post-disposal

Credential caching flaw:

  • Cache key uses credential type (GetType().FullName) but CreateChannel() captures credential instance
  • Different TokenCredential instances with same type (e.g., two ManagedIdentityCredential with different client IDs) incorrectly share channels
  • Config reload scenarios will reuse channels with stale credentials

Awaiting confirmation

No changes applied yet—waiting for user direction on whether to:

  1. Fix in this PR
  2. Handle via separate mechanism

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Fix GrpcChannel handle leak in AzureManaged backend Fix race condition and credential caching in GrpcChannel lifecycle Jan 28, 2026
Copilot AI requested a review from torosent January 28, 2026 16:50
@torosent torosent marked this pull request as ready for review January 28, 2026 18:06
@torosent torosent merged commit 9a005e5 into torosent/fix-grpc-channel-dispose Jan 28, 2026
2 checks passed
@torosent torosent deleted the copilot/sub-pr-625 branch January 28, 2026 18:06
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.

2 participants