Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dont sync client if client call failed, add retry #76

Merged
merged 2 commits into from
Jul 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions Sources/API/ClerkAPIClientDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,15 @@ final class ClerkAPIClientDelegate: APIClientDelegate, Sendable {
}

func client(_ client: APIClient, shouldRetry task: URLSessionTask, error: any Error, attempts: Int) async throws -> Bool {

if attempts == 1 {
// try to get the client in sync with the server on errors
_ = try? await Client.get()
if let lastPathComponent = task.originalRequest?.url?.pathComponents.last, lastPathComponent != "client" {
// try to get the client in sync with the server on errors if the original request wasn't a get client
_ = try? await Client.get()
}
return true
}

return false
}

Expand Down
Loading