Skip to content

Fix gRPC channel cache key to include all channel-affecting properties#626

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

Fix gRPC channel cache key to include all channel-affecting properties#626
torosent merged 2 commits intotorosent/fix-grpc-channel-disposefrom
copilot/sub-pr-625

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 28, 2026

The gRPC channel cache key only included optionsName, EndpointAddress, and TaskHubName, causing stale channels to be reused when other channel-affecting properties changed (e.g., via options reload).

Changes

  • Worker extensions: Cache key now includes ResourceId, credential type, AllowInsecureCredentials, and WorkerId
  • Client extensions: Cache key now includes ResourceId, credential type, AllowInsecureCredentials, and RetryOptions
  • Delimiter: Changed from : to \u001F (Unicode unit separator) to avoid collisions with endpoint URIs
  • Tests: Added 8 new tests verifying separate channels for distinct configurations; fixed 4 existing tests to use async disposal

Impact

Before this fix, changing any of these properties while keeping the same endpoint/task hub would incorrectly reuse the cached channel:

// These would incorrectly share a channel despite different ResourceIds
builder.UseDurableTaskScheduler(endpoint, hub, cred, opts => opts.ResourceId = "https://durabletask.io");
builder.UseDurableTaskScheduler(endpoint, hub, cred, opts => opts.ResourceId = "https://custom.io");

Now each unique configuration creates its own channel as intended.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Update cache key generation in both Worker and Client extensions to include all properties that affect CreateChannel behavior:
- ResourceId
- Credential type (full type name)
- AllowInsecureCredentials
- WorkerId (Worker only)
- RetryOptions (Client only)

This ensures that channels are not incorrectly reused when these properties change while EndpointAddress/TaskHubName remain the same.

Co-authored-by: torosent <17064840+torosent@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix feedback on GrpcChannel handle leak in AzureManaged backend Fix gRPC channel cache key to include all channel-affecting properties Jan 28, 2026
Copilot AI requested a review from torosent January 28, 2026 15:53
@torosent torosent marked this pull request as ready for review January 28, 2026 16:01
@torosent torosent merged commit 5ec4cd9 into torosent/fix-grpc-channel-dispose Jan 28, 2026
3 checks passed
@torosent torosent deleted the copilot/sub-pr-625 branch January 28, 2026 16:01
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