Does `URLSession.shared.dataTask(from:)` check for cancellation while the request is in flight or once it returns?

I'm executing code like:

DashboardView()
    .task {
        await model.fetchCandidates()
     }

And the docs for View.task(priority:_:) state:

SwiftUI will automatically cancel the task at some point after the view disappears before the action completes.

I'm wondering what would happen if the view disappeared while the request was in-flight. Would the task cancellation error be thrown, or do I have to check after the statement completes if the task was cancelled manually?

Here's an experiment to try to see. The download below typically takes 5 seconds to download in my case. With the cancellation added after 2 seconds, an error immediately prints which seems to suggest it was cancelled in-flight.

    func testCancellation() async throws {
        let task = Task {
            let url = URL(string: "https://codeload.github.com/apple/swift-llvm/zip/refs/tags/swift-4.2.2-RELEASE")!
            do {
                let (data, response) = try await URLSession.shared.data(from: url, delegate: delegate)
                print(response)
            } catch {
                print("error: \(error)")
            }
        }
        
        try await Task.sleep(until: .now.advanced(by: .seconds(2.0)))
        task.cancel()
    }
}
Error Domain=NSURLErrorDomain Code=-999 "cancelled" UserInfo={NSErrorFailingURLStringKey=https://codeload.github.com/apple/swift-llvm/zip/refs/tags/swift-4.2.2-RELEASE, NSErrorFailingURLKey=https://codeload.github.com/apple/swift-llvm/zip/refs/tags/swift-4.2.2-RELEASE, _NSURLErrorRelatedURLSessionTaskErrorKey=(
    "LocalDataTask <36075FD3-99B3-491B-A383-DDF42ABB204A>.<1>"
), _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <36075FD3-99B3-491B-A383-DDF42ABB204A>.<1>, NSLocalizedDescription=cancelled}
``