Skip to content

Conversation

@itsmeichigo
Copy link
Contributor

@itsmeichigo itsmeichigo commented Sep 3, 2025

Part of WOOMOB-1126

Description

This PR adds retry logic for REST requests in AlamofireNetwork to fall back to Jetpack proxied requests and mark sites as unsupported for application passwords following the plan in pe5sF9-4ye-p2#comment-4787.

Most changes come from unit tests.

Testing steps

Run test cases 4 & 5 in this test plan: pe5sF9-4Am-p2.

Testing information

  • Tested and verify the above test cases with simulator iPhone 16 iOS 18.2
  • Added unit tests to verify the new logic.

Screenshots

No UI changes.


  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

@itsmeichigo itsmeichigo added this to the 23.2 milestone Sep 3, 2025
@itsmeichigo itsmeichigo added the type: task An internally driven task. label Sep 3, 2025
@dangermattic
Copy link
Collaborator

dangermattic commented Sep 3, 2025

1 Warning
⚠️ This PR is assigned to the milestone 23.2. This milestone is due in less than 2 days.
Please make sure to get it merged by then or assign it to a milestone with a later deadline.

Generated by 🚫 Danger

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Sep 3, 2025

App Icon📲 You can test the changes from this Pull Request in WooCommerce iOS Prototype by scanning the QR code below to install the corresponding build.

App NameWooCommerce iOS Prototype
Build Numberpr16075-501cfbe
Version23.1
Bundle IDcom.automattic.alpha.woocommerce
Commit501cfbe
Installation URL1ff18ng1sdng0
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@itsmeichigo itsmeichigo marked this pull request as ready for review September 3, 2025 11:18
Copy link
Contributor

@RafaelKayumov RafaelKayumov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Testing steps work as described. Tested all snippets for 4th scenario. Requests fell back to JP proxy and reloaded orders list. For the 5th scenario snippet it took a few order list load re-triggers to completely fallback to JP.

private var appPasswordFailures: [Int64: Int] = [:]

/// Keeps track of retried requests when direct requests fail
private var retriedJetpackRequests: [RetriedJetpackRequest] = []
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it planned to clean-up the collection of retried requests? At the moment I see that specific retried requests only get removed in flagSiteAsUnsupportedForAppPasswordIfNeeded. I wonder if we should also remove those upon successful completion after a retry?

Copy link
Contributor Author

@itsmeichigo itsmeichigo Sep 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In flagSiteAsUnsupportedForAppPasswordIfNeeded the sites are flagged when retry succeeds (hence the check if failure == nil). The cleanup is done outside of the if check, meaning it's always done disregard of the result of the retry. @RafaelKayumov please let me know if there's still something missing.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@itsmeichigo Ok, makes sense now. I missed IfNeeded part of naming in my logic. So the flagSiteAsUnsupportedForAppPasswordIfNeeded is executed in the happy case as well skipping the failure handling and going directly to request removal.
Ship it

@itsmeichigo itsmeichigo merged commit 2e05cde into trunk Sep 4, 2025
17 checks passed
@itsmeichigo itsmeichigo deleted the woomob-1126-direct-requests-failures branch September 4, 2025 10:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: task An internally driven task.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants