Skip to content

Commit

Permalink
Hotfix for dApp validation error (#1257)
Browse files Browse the repository at this point in the history
  • Loading branch information
GhenadieVP authored Aug 6, 2024
1 parent b8bec88 commit 2a6ca95
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Aux/Config/Common.xcconfig
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// MARK: - Custom flags

/// Application version shared across all targets and flavours
APP_VERSION = 1.8.1
APP_VERSION = 1.8.2

/// App Icon base name
APP_ICON = AppIcon
Expand Down
26 changes: 25 additions & 1 deletion RadixWallet/Clients/HTTPClient/HTTPClient+Live.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,31 @@ extension HTTPClient {

return .init(
executeRequest: { request, acceptedStatusCodes in
let (data, urlResponse) = try await session.data(for: request)
let (data, urlResponse) = try await {
// Retrying only once seems to be enough, but better to be on the safe side and retry more.
var retryAttempts = 5
while retryAttempts > 0 {
do {
return try await session.data(for: request)
} catch {
// Handle the very obscure error when the CFNetwork drops the request after it being sent.
// Note that NSURLErrorNetworkConnectionLost seems to be an opaque error hiding some other
// possible error withing CFNetwork, it does not literally mean that hte network connection
// was actually lost. This error will usually be thrown when the request was made right after
// the app did come to foreground, it happens seldomly, but consistently.
// As a workaround - retry the request if it failed initially.
if let nsError = error as NSError?,
nsError.domain == NSURLErrorDomain,
nsError.code == NSURLErrorNetworkConnectionLost
{
retryAttempts -= 1
continue
}
throw error
}
}
throw RequestRetryAttemptsExceeded()
}()

guard let httpURLResponse = urlResponse as? HTTPURLResponse else {
throw ExpectedHTTPURLResponse()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ public struct ExpectedHTTPURLResponse: Swift.Error {
public init() {}
}

// MARK: - RequestRetryAttemptsExceeded
public struct RequestRetryAttemptsExceeded: Swift.Error {
public init() {}
}

// MARK: - BadHTTPResponseCode
public struct BadHTTPResponseCode: LocalizedError {
public let got: Int
Expand Down

0 comments on commit 2a6ca95

Please sign in to comment.