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

Remove manual task clearing in URLSessionClient invalidate #1443

Merged
merged 1 commit into from
Oct 16, 2020
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
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