Skip to content

Commit

Permalink
fix: offline directly after receive bad url error
Browse files Browse the repository at this point in the history
  • Loading branch information
sojingle committed Jan 31, 2025
1 parent bcd4a44 commit 3998f3f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions Sources/Amplitude/Utilities/EventPipeline.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ public class EventPipeline {
let storage: Storage?
let logger: (any Logger)?
let configuration: Configuration
var maxRetryInterval: TimeInterval = 60
var maxRetryCount: Int = 6
let maxRetryInterval: TimeInterval = 60
let maxRetryCount: Int = 6

@Atomic internal var eventCount: Int = 0
internal var flushTimer: QueueTimer?
Expand Down Expand Up @@ -119,7 +119,7 @@ public class EventPipeline {
self.currentUpload = nil
}
self.configuration.offline = true
self.logger?.log(message: "Request failed more than \(self.maxRetryCount) times, marking offline")
self.logger?.error(message: "Request failed more than \(self.maxRetryCount) times, marking offline")
} else {
// Don't send the next event file if we're being deallocated
let nextFileBlock: () -> Void = { [weak self] in
Expand All @@ -135,7 +135,7 @@ public class EventPipeline {
} else {
let sendingInterval = min(self.maxRetryInterval, pow(2, Double(failures - 1)))
self.uploadsQueue.asyncAfter(deadline: .now() + sendingInterval, execute: nextFileBlock)
self.logger?.debug(message: "Request failed \(failures) times, send next event file in \(sendingInterval) seconds")
self.logger?.error(message: "Request failed \(failures) times, send next event file in \(sendingInterval) seconds")
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/Amplitude/Utilities/HttpClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class HttpClient {
let nsError = error as NSError
if nsError.domain == NSURLErrorDomain {
switch nsError.code {
case NSURLErrorCannotConnectToHost, NSURLErrorNetworkConnectionLost, NSURLErrorCannotFindHost, NSURLErrorAppTransportSecurityRequiresSecureConnection, NSURLErrorNotConnectedToInternet:
case NSURLErrorCannotConnectToHost, NSURLErrorNetworkConnectionLost, NSURLErrorCannotFindHost, NSURLErrorAppTransportSecurityRequiresSecureConnection, NSURLErrorNotConnectedToInternet, NSURLErrorBadURL:
logger?.error(message: "Conection failed with error: \(error.localizedDescription), marking offline")
configuration.offline = true
default:
Expand Down

0 comments on commit 3998f3f

Please sign in to comment.