Skip to content

Commit

Permalink
Don't wait for task if not refreshing session
Browse files Browse the repository at this point in the history
  • Loading branch information
leoMehlig committed Apr 22, 2024
1 parent 4293cca commit df9e27a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Sources/Auth/Internal/SessionManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ private actor _DefaultSessionManager {
private var logger: (any SupabaseLogger)?

func session(shouldValidateExpiration: Bool) async throws -> Session {
if let task {
return try await task.value
}

guard let currentSession = try storage.getSession() else {
throw AuthError.sessionNotFound
Expand All @@ -55,6 +52,10 @@ private actor _DefaultSessionManager {
return currentSession.session
}

if let task {
return try await task.value
}

task = Task {
defer { task = nil }

Expand Down

0 comments on commit df9e27a

Please sign in to comment.