Good afternoon! I ran into the following problem: there is an execute function.
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
@discardableResult
open func execute() async throws -> Response<T> {
try await withTaskCancellationHandler {
try Task.checkCancellation()
return try await withCheckedThrowingContinuation { continuation in
guard !Task.isCancelled else {
continuation.resume(throwing: CancellationError())
return
}
self.execute { result in
switch result {
case let .success(response):
continuation.resume(returning: response)
case let .failure(error):
continuation.resume(throwing: error)
}
}
}
} onCancel: {
self.requestTask.cancel()
Here I have unexpected behavior for me. I am trying to get data from the server by the link. My request occurs in refreshable. It looks like this:
...
.refreshable {
await loadBalanceDetails()
}
and
private func loadBalanceDetails() async {
guard let error = await viewModel.fetchOperations(dateFrom: viewModel.startDate, dateTo: viewModel.endDate) else {
return
}
await MainActor.run {
switch error {
case .connectivityError:
toastAlert = .noConnectionError
case .remoteError:
toastAlert = .remoteError
default:
break
}
}
}
During the call, the following happens:
SWIFT TASK CONTINUATION MISUSE: execute() leaked its continuation! 2023-08-12 19:33:13.385396+0300 testProject Debug[...] SWIFT TASK CONTINUATION MISUSE: execute() leaked its continuation!
During.onAppear everything loads fine, but the trouble is with refreshable. Please help me figure out why this error pops up.
It should be so that when you pull to refresh, the data is updated and appears, but instead, this error in the log simply occurs and the spinner loads endlessly