File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed
WooCommerce/Classes/Yosemite Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -534,6 +534,26 @@ private extension DefaultStoresManager {
534534 dispatch ( action)
535535 }
536536
537+ /// Implements a retry logic for fetching the store information i.e. `store_id` to reduce the chances of it being missing.
538+ /// We use three attempts with an exponential backoff.
539+ ///
540+ @MainActor
541+ func fetchSystemInformationAndRetryIfFails( siteID: Int64 ,
542+ retryCount: Int = 0 ) async -> SystemInformation ? {
543+ guard retryCount <= 3 else {
544+ return nil
545+ }
546+
547+ let waitTime = Int ( pow ( Double ( 2 ) , Double ( retryCount) ) )
548+ try ? await Task . sleep ( for: . seconds( waitTime) )
549+
550+ if let info = await synchronizeSystemInformation ( siteID: siteID) {
551+ return info
552+ } else {
553+ return await fetchSystemInformationAndRetryIfFails ( siteID: siteID, retryCount: retryCount + 1 )
554+ }
555+ }
556+
537557 /// Synchronizes all system information for the store with specified ID.
538558 /// When finished, loads the store uuid into the session.
539559 ///
@@ -646,7 +666,7 @@ private extension DefaultStoresManager {
646666 Task { @MainActor in
647667 // Order statuses and system plugins syncing are required outside of snapshot tracking.
648668 async let orderStatuses = retrieveOrderStatus ( with: siteID)
649- async let systemInformation = synchronizeSystemInformation ( siteID: siteID)
669+ async let systemInformation = fetchSystemInformationAndRetryIfFails ( siteID: siteID)
650670
651671 trackSnapshotIfNeeded ( siteID: siteID, orderStatuses: await orderStatuses, systemPlugins: await systemInformation? . systemPlugins)
652672 }
You can’t perform that action at this time.
0 commit comments