Skip to content

Commit

Permalink
Merge pull request #1443 from philfi/main
Browse files Browse the repository at this point in the history
Remove manual task clearing in URLSessionClient invalidate
  • Loading branch information
designatednerd authored Oct 16, 2020
2 parents ee7e47c + 20e69d2 commit 94fcd28
Showing 1 changed file with 4 additions and 18 deletions.
22 changes: 4 additions & 18 deletions Sources/Apollo/URLSessionClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,29 +65,15 @@ open class URLSessionClient: NSObject, URLSessionDelegate, URLSessionTaskDelegat
self.session = nil
self.clearAllTasks()
}

guard let session = self.session else {
// Session's already gone, just cleanup.
cleanup()
return
}

let currentTaskIDs = self.tasks.value.keys
if #available(OSX 10.11, iOS 9.0, *) {
session.getAllTasks { [weak self] tasks in
for task in tasks {
if currentTaskIDs.contains(task.taskIdentifier) {
self?.cancel(task: task)
}
}

cleanup()
}
} else {
// Fallback on earlier versions - note that per docs this does *not* cancel all operations on the shared session.
session.invalidateAndCancel()
cleanup()
}

session.invalidateAndCancel()
cleanup()
}

/// Clears underlying dictionaries of any data related to a particular task identifier.
Expand Down

0 comments on commit 94fcd28

Please sign in to comment.