Skip to content

Commit

Permalink
fix: proteus send message error missing logic - WPB-16116 (#2535)
Browse files Browse the repository at this point in the history
Co-authored-by: Jullian Mercier <[email protected]>
  • Loading branch information
github-actions[bot] and jullianm authored Feb 13, 2025
1 parent de14595 commit c26a23b
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,15 +173,15 @@ public final class MessageSender: MessageSenderInterface {
.broadcastProteusMessage(message: messageData)
await handleProteusSuccess(message: message, messageSendingStatus: messageStatus, response: response)
} catch let networkError as NetworkError {
let retryOperation: () async throws -> Void = { [weak self] in
let operation: () async throws -> Void = { [weak self] in
try await self?.broadcastMessage(message: message)
}

try await handleNetworkError(
networkError,
message: message,
apiVersion: apiVersion,
retryOperation: retryOperation
operation: operation
)
}
}
Expand Down Expand Up @@ -239,15 +239,15 @@ public final class MessageSender: MessageSenderInterface {
)
await handleProteusSuccess(message: message, messageSendingStatus: messageStatus, response: response)
} catch let networkError as NetworkError {
let retryOperation: () async throws -> Void = { [weak self] in
let operation: () async throws -> Void = { [weak self] in
try await self?.sendMessage(message: message)
}

try await handleNetworkError(
networkError,
message: message,
apiVersion: apiVersion,
retryOperation: retryOperation
operation: operation
)
}
}
Expand All @@ -256,11 +256,12 @@ public final class MessageSender: MessageSenderInterface {
_ networkError: NetworkError,
message: any ProteusMessage,
apiVersion: APIVersion,
retryOperation: () async throws -> Void
operation: () async throws -> Void
) async throws {
do {
let missingClients = try await handleProteusFailure(message: message, networkError)
try await sessionEstablisher.establishSession(with: missingClients, apiVersion: apiVersion)
try await operation()
} catch let error as MessageSendError {
guard retryCount < maxRetryAttempts else {
retryCount = 0
Expand All @@ -269,7 +270,7 @@ public final class MessageSender: MessageSenderInterface {

retryCount += 1

try await retryOperation()
try await operation()
} catch {
throw error
}
Expand Down

0 comments on commit c26a23b

Please sign in to comment.