Skip to content

Use fallback API hosts when receiving server down response #2368

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

ajpallares
Copy link
Member

Checklist

  • If applicable, unit tests
  • If applicable, create follow-up issues for purchases-ios and hybrids

Description

This PR implements a retry mechanism using fallback URL hosts for supported requests that fail with a server down error

Notes

  • Only some requests support a fallback API host. Currently only getCustomerInfo and getProductEntitlementMapping support it.
  • AppConfig now has a fallbackBaseURLs containing the list of hosts, in order of preference, to use for supported requests.
  • When a request's response is a server error (5XX), the same request is immediately retried with the next host of the array.
  • The logic is implemented per-request: that is, if a request fails with a server-down error for host 1 and then falls back and succeeds for host 2, then all future requests will use again host 1 initially. No state is held between different requests.
  • No fallback retries happen when using a proxy URL

iOS PR counterpart --> RevenueCat/purchases-ios#4970

Copy link

codecov bot commented Apr 21, 2025

Codecov Report

Attention: Patch coverage is 83.33333% with 9 lines in your changes missing coverage. Please review.

Project coverage is 79.93%. Comparing base (be4ef49) to head (f47b681).

Files with missing lines Patch % Lines
...revenuecat/purchases/common/networking/Endpoint.kt 42.85% 0 Missing and 8 partials ⚠️
...tlin/com/revenuecat/purchases/common/HTTPClient.kt 96.29% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2368      +/-   ##
==========================================
+ Coverage   79.92%   79.93%   +0.01%     
==========================================
  Files         284      284              
  Lines       10151    10204      +53     
  Branches     1433     1448      +15     
==========================================
+ Hits         8113     8157      +44     
  Misses       1422     1422              
- Partials      616      625       +9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant