Update Polly to 8.7.0 - #7742
Open
gitmln wants to merge 3 commits into
Open
Conversation
With Polly 8.4.2, a gRPC call that the caller cancels while an attempt is in flight, and whose attempt then completes with a retryable failure, ends with StatusCode.Unavailable instead of StatusCode.Cancelled. The retry strategy returns the last outcome instead of throwing when the token is cancelled; Polly changed this in 8.5.2 (App-vNext/Polly#2456). The test fails on main and passes with the Polly packages at 8.7.0.
Bumps Polly, Polly.Core, Polly.Extensions, Polly.RateLimiting and Polly.Testing together. 8.7.0 declares the same dependencies and target frameworks as 8.4.2. Makes SayHello_StandardResilience_CancelledWhileAttemptCompletes_Cancelled pass; the remaining tests in Microsoft.Extensions.Http.Resilience.Tests and Microsoft.Extensions.Resilience.Tests are unaffected.
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The change is narrowly scoped (targeted regression test + consistent package version bump) and directly validates the intended behavioral fix.
Pull request overview
Updates the repository’s pinned Polly dependencies to address a gRPC cancellation behavior regression when using AddStandardResilienceHandler, and adds a regression test to lock in the expected StatusCode.Cancelled outcome.
Changes:
- Added a gRPC resilience regression test covering “caller cancels while a retryable transient failure completes”.
- Updated pinned Polly package versions (runtime + testing) to
8.7.0to pick up the fixed cancellation behavior.
File summaries
| File | Description |
|---|---|
| test/Libraries/Microsoft.Extensions.Http.Resilience.Tests/Resilience/GrpcResilienceTests.cs | Adds a regression test for cancellation during a retryable failure and extends client creation to allow injecting a primary handler. |
| eng/packages/Tests.props | Bumps Polly.Testing to 8.7.0 for test dependency alignment. |
| eng/packages/General.props | Bumps Polly, Polly.Core, Polly.Extensions, and Polly.RateLimiting to 8.7.0 to pick up the cancellation semantics fix. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
CA2000 flagged the TestHandlerStub created inline in SayHello_StandardResilience_CancelledWhileAttemptCompletes_Cancelled. CreateClient now takes a Func<HttpMessageHandler>, matching how the other tests hand primary handlers to ConfigurePrimaryHttpMessageHandler.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #7741
With Polly 8.4.2 the retry strategy returns the last failed outcome instead of throwing when the caller's token is cancelled. Behind
AddStandardResilienceHandler, a gRPC client that the caller cancels during an attempt ending in a retryable failure therefore reportsStatusCode.Unavailable(orUnknown/Internal, depending on the failure) instead ofStatusCode.Cancelled. Polly changed this in 8.5.2 (App-vNext/Polly#2456).Two commits:
GrpcResilienceTestsfor that scenario — fails onmain;The behaviour change is the fix: with a cancelled token, a retryable failure now surfaces as
OperationCanceledExceptionrather than as the outcome of the last attempt. Non-retryable outcomes are returned as before.I used Claude Code for the investigation and to draft the test; I ran the tests myself.
Microsoft Reviewers: Open in CodeFlow