Skip to content

Commit

Permalink
Fix actuallyCancel logic
Browse files Browse the repository at this point in the history
  • Loading branch information
brianmichel committed Jan 9, 2024
1 parent f20c806 commit 0f9be90
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Sources/_Helpers/URLSession+AsyncAwait.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ private actor URLSessionTaskCancellationHelper {
}

private func actuallyCancel() {
state = .cancelled

// Handle whatever needs to be done based on the current state
switch state {
case let .registered(task):
task.cancel()
Expand All @@ -64,6 +63,9 @@ private actor URLSessionTaskCancellationHelper {
case .initialized:
break
}

// Set state into cancelled to short circuit subsequent cancellations or registrations.
state = .cancelled
}
}

Expand Down

0 comments on commit 0f9be90

Please sign in to comment.