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

I'm executing code like:

    .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: "")!
            do {
                let (data, response) = try await url, delegate: delegate)
            } catch {
                print("error: \(error)")
        try await Task.sleep(until: .now.advanced(by: .seconds(2.0)))
Error Domain=NSURLErrorDomain Code=-999 "cancelled" UserInfo={NSErrorFailingURLStringKey=, NSErrorFailingURLKey=, _NSURLErrorRelatedURLSessionTaskErrorKey=(
    "LocalDataTask <36075FD3-99B3-491B-A383-DDF42ABB204A>.<1>"
), _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <36075FD3-99B3-491B-A383-DDF42ABB204A>.<1>, NSLocalizedDescription=cancelled}