diff --git a/Sources/ConfidenceProvider/Apply/FlagApplierWithRetries.swift b/Sources/ConfidenceProvider/Apply/FlagApplierWithRetries.swift index b6dbb173..f5813677 100644 --- a/Sources/ConfidenceProvider/Apply/FlagApplierWithRetries.swift +++ b/Sources/ConfidenceProvider/Apply/FlagApplierWithRetries.swift @@ -37,26 +37,26 @@ final class FlagApplierWithRetries: FlagApplier { public func apply(flagName: String, resolveToken: String) async { let applyTime = Date.backport.now - async let (data, added) = await cacheDataInteractor.add( + let (data, added) = await cacheDataInteractor.add( resolveToken: resolveToken, flagName: flagName, applyTime: applyTime ) - guard await added == true else { + guard added == true else { // If record is found in the cache, early return (de-duplication). // Triggerring batch apply in case if there are any unsent events stored await triggerBatch() return } - await self.writeToFile(data: data) + self.writeToFile(data: data) await triggerBatch() } // MARK: private private func triggerBatch() async { - async let cacheData = await cacheDataInteractor.cache + let cacheData = await cacheDataInteractor.cache await cacheData.resolveEvents.asyncForEach { resolveEvent in let appliesToSend = resolveEvent.events.filter { $0.status == .created } .chunk(size: 20) diff --git a/Sources/ConfidenceProvider/Http/NetworkClient.swift b/Sources/ConfidenceProvider/Http/NetworkClient.swift index 585cb5c3..0ba073b4 100644 --- a/Sources/ConfidenceProvider/Http/NetworkClient.swift +++ b/Sources/ConfidenceProvider/Http/NetworkClient.swift @@ -77,8 +77,8 @@ final class NetworkClient: HttpClient { let retryWait: TimeInterval? = retryHandler.retryIn() do { - async let (data, response) = await self.session.data(for: request) - guard let httpResponse = try? await response as? HTTPURLResponse else { + let (data, response) = try await self.session.data(for: request) + guard let httpResponse = response as? HTTPURLResponse else { await completion(nil, nil, HttpClientError.invalidResponse) return } @@ -87,11 +87,6 @@ final class NetworkClient: HttpClient { await self.perform(request: request, retry: retry, completion: completion) return } - guard let data = try? await data else { - let error = ConfidenceError.internalError(message: "Unable to complete request") - await completion(httpResponse, nil, error) - return - } await completion(httpResponse, data, nil) } catch { if self.shouldRetry(error: error), let retryWait {