-
Notifications
You must be signed in to change notification settings - Fork 335
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
Only Retry POST Receipt Paths for 429 #4107
Conversation
isRetryable = Bool(isRetryableString.lowercased()) ?? true | ||
} else { | ||
isRetryable = true | ||
let doesServerAllowRetryString = urlResponse.value(forHTTPHeaderField: ResponseHeader.isRetryable.rawValue) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No change in the logic, just renaming isRetryable
to doesServerAllowRetry
to be more clear
@RCGitBot please test |
Some of the test checks look a little funny right now because it took me a moment to figure out how to run all of the tests, I'll make sure they're all good to go before merging 💪 |
@@ -173,7 +175,7 @@ class OtherIntegrationTests: BaseBackendIntegrationTests { | |||
try AvailabilityChecks.iOS15APIAvailableOrSkipTest() | |||
|
|||
let result = try await self.purchases.productEntitlementMapping().entitlementsByProduct | |||
expect(result).to(haveCount(18)) | |||
expect(result).to(haveCount(21)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure when (the audit logs aren't loading for me), but we now have 21 iOS products in the StoreKit Integration Tests app instead of 18
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm looking into this a little more to confirm why this has changed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The most recently added product to the project was on June 25, so this isn't an issue with a new product being present. Continuing to dig 👀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test is currently failing in main with the value 18
, but passed during yesterday's release pipeline 🧐
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@RevenueCat/coresdk thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Josh and I took a look at some network logs and found that the backend was returning 18 mappings on Tuesday when the test passed, but is now returning 21 in the network calls to /v1/product_entitlement_mapping
. This is happening on this branch, main, and the 4.32.2 release. We now believe that 21 is the correct number and are following up with the backend team to investigate what caused the change to take so long to appear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looking good so far
var doesServerAllowRetry: Bool = true | ||
if let doesServerAllowRetryString = doesServerAllowRetryString { | ||
doesServerAllowRetry = Bool(doesServerAllowRetryString.lowercased()) ?? true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sure this version is more clever, but it was kinda clearer before the ternary IMO
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm okay reverting it! I'll keep the name doesServerAllowRetry
over isRetryable
though 😅
|
||
init(method: Method, path: HTTPRequest.Path, nonce: Data? = nil) { | ||
self.init(method: method, requestPath: path, nonce: nonce) | ||
/// Whether or not this reqeust should be retried by the HTTPClient for certain status codes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo request
@@ -173,7 +175,7 @@ class OtherIntegrationTests: BaseBackendIntegrationTests { | |||
try AvailabilityChecks.iOS15APIAvailableOrSkipTest() | |||
|
|||
let result = try await self.purchases.productEntitlementMapping().entitlementsByProduct | |||
expect(result).to(haveCount(18)) | |||
expect(result).to(haveCount(21)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@RevenueCat/coresdk thoughts?
@@ -935,6 +935,7 @@ class StoreKit1IntegrationTests: BaseStoreKitIntegrationTests { | |||
} | |||
|
|||
func testVerifyPurchaseGrantsEntitlementsThroughOnRetryAfter429() async throws { | |||
defer { HTTPStubs.removeAllStubs() } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this just be a setup or teardown?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved it to the tearDown
functions 😎
Hey @aboedo! Since your last review, I've made the following changes: Code Changes
Test Fixes/Clarifications
This should be ready for another look! |
Description
This PR modifies the HTTPClient's retry logic to only perform retries on requests to the
/v1/receipts
URL path that result in a 429 status code.Testing
isRetryable
field correctlyHTTPClient.Request
to ensure that theisRetryable
field is being set properly/v1/subscribers/identify
)