Repository navigation
[installer] Replace Polly with a small retry loop - #13452
Merged
simonrozsival merged 2 commits intoNov 10, 2026
Merged
Conversation
CheckIfNetworkIsAvailableAsync was the only Polly consumer. Replace the WaitAndRetryAsync policy with a private loop that keeps the same retry conditions (TimeoutException/TaskCanceledException incl. subclasses), 3 retries with a fixed 1s delay, the same warning message, ConfigureAwait (false) semantics, and capture-all failure -> false. Remove the Polly package reference from Xamarin.Installer.AndroidSDK, Xamarin.Installer.Build.Tasks and Xamarin.Android.Build.Tests, and the PollyVersion property. Removes the public Helper.ResiliencyPolicies type, which had no in-repo callers. Co-authored-by: Copilot App <[email protected]>
Catch only terminal TimeoutException and TaskCanceledException when the network retry budget is exhausted. Unlike Polly ExecuteAndCaptureAsync, unexpected errors escaping the network check or retry logging now fault the returned task instead of silently becoming false. The underlying network check still logs and handles its existing failure cases. Rebuilt installer tasks in Release and compared the production Helper against the main-baseline binary: HTTP 200, HTTP 500, refused connection, two timeouts then success, and retry exhaustion retain identical results, requests and warnings. An injected logger failure returns false on main and propagates on the candidate as intended. All checks ran under the shared validation lock; artifacts are in session files/revise-retry.log. Compatibility caveat remains: the earlier removal of public Helper.ResiliencyPolicies is source/binary breaking for any external consumers. Co-authored-by: Copilot App <[email protected]>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The replacement retry loop lacks checked-in tests for recovery, exhaustion, derived timeout/cancellation exceptions, and retry-logger failures, leaving these behaviors unprotected against CI regressions.
1 open issue
What changed in this PR
Replaces the installer’s only Polly usage with a private retry loop, reducing dependency and policy-allocation overhead without depending on #12988.
Changes:
- Preserves up to four timeout/cancellation attempts, one-second retry delays, and retry warnings.
- Allows unexpected exceptions to propagate and removes the public
Helper.ResiliencyPoliciesAPI—an acknowledged compatibility break. - Removes Polly package references and its shared version property.
| File | Description |
|---|---|
src/Xamarin.Installer.Build.Tasks/Xamarin.Installer.Build.Tasks.csproj |
Removes the Polly package reference. |
src/Xamarin.Installer.AndroidSDK/Xamarin.Installer.AndroidSDK/Common/Helper.cs |
Replaces the Polly policy with a private retry loop and narrows exception handling. |
src/Xamarin.Installer.AndroidSDK/Xamarin.Installer.AndroidSDK.csproj |
Removes the Polly dependency and asset configuration. |
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Xamarin.Android.Build.Tests.csproj |
Removes the test project’s Polly reference. |
Directory.Build.props |
Removes the unused Polly version property. |
Review effort: Balanced
| for (int attempt = 0; ; attempt++) { | ||
| try { | ||
| return await action ().ConfigureAwait (false); | ||
| } catch (Exception exception) when (attempt < retryCount && (exception is TimeoutException || exception is TaskCanceledException)) { |
simonrozsival
enabled auto-merge (squash)
November 10, 2026 17:16
Member
Author
|
@dalexsoto review |
jonathanpeppers
approved these changes
Nov 10, 2026
simonrozsival
deleted the
simonrozsival-installer-polly-retry-evaluation
branch
November 10, 2026 18:40
simonrozsival
added a commit
that referenced
this pull request
Nov 10, 2026
Context: #13452 The rebase conflict resolution restored Polly package references even though main had already replaced the installer retry policy. Remove those references and the unused version property; the retry implementation remains unchanged. Co-authored-by: Copilot App <[email protected]>
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.

Context: f94d880
Context: #12988
Xamarin.Installer.AndroidSDK.Manager.Helper.CheckIfNetworkIsAvailableAsync()was the only in-tree consumer of Polly. Constructing a general-purpose policy for this check adds an assembly and allocation overhead. Replace it with a private retry loop and remove the Polly package references and version property.The check still makes at most four attempts for
TimeoutExceptionorTaskCanceledException, including derived exceptions, with a one-second delay and the same warning on each retry. Terminal timeouts and cancellations returnfalse. Unlike Polly'sExecuteAndCaptureAsync, unexpected exceptions escaping the existing network check or retry logging now propagate instead of being silently converted tofalse.Compatibility: This removes the public nested
Helper.ResiliencyPoliciestype and itsAsyncRetryIfTimeout()method. There are no in-repository callers, but external users of that API will experience a source and binary break. #12988 touches the same installer project files but is not a prerequisite.Measurements: On macOS arm64, an in-process BenchmarkDotNet comparison of the baseline and the initial candidate measured a completed delegate at 300.4 ns / 1.08 KB versus 7.292 ns / 0 B. A separate local HTTP first-call comparison, with the HTTP stack warmed and 25 alternating fresh-process pairs, had medians of 9.394 ms / 60,544 B versus 6.390 ms / 47,280 B. These measurements predate the final catch narrowing and do not establish an end-to-end startup improvement; no in-tree call sites for the network check were found.
Validation: All commands ran under the shared validation lock.
dotnet build src/Xamarin.Installer.Build.Tasks/Xamarin.Installer.Build.Tasks.csproj -c Release -nologo -v:q— passed with 10 existing SourceLink/Git warnings.dotnet "$v/bin/$v/Harness.dll" equiv "$m"— passed with the session-local harness for both baseline and candidate: HTTP 200, HTTP 500, refused connection, two timeouts followed by success, and retry exhaustion had matching results, requests, and warnings. An injected logger failure was intentionally converted tofalseby the baseline and propagated by the candidate.No repository tests were added; the comparison harness is session-local.
AndroidDependenciesTests.InstallAndroidDependenciesTestwas not run: it does not call this network-check method and downloads an SDK/JDK.