NetworkConnection - Send not throwing?

Hi,

I played around the last days with the new NetworkConnection API from Network framework that supports structured concurrency. I discovered a behavior, which is unexpected from my understanding.

Let's say you have a dead endpoint or something that does not exist. Something where you receive a noSuchRecord error. When I then try to send data, I would expect that the send function throws an error but this does not happen. The function now suspends indefinitely which is well not a great behavior.

Example simplified:

func send() async {
    let connection = NetworkConnection(to: .hostPort(host: "apple.co.com", port: 8080)) {
        TCP()
    }
    do {
        try await connection.send("Hello World!".raw)
    } catch {
        print(error)
    }
}

I'm not sure if this is the intended behavior or how this should be handled.

Thanks and best regards, Vinz

NetworkConnection - Send not throwing?
 
 
Q