Why `AsyncStream` breaks structured concurrency?

While this setup works it is still unstructured. I would recommend to use the makeStream(of:) factory method on AsyncStream and then pass the continuation into one child task that produces the elements and the stream into another child task that consumes the events.

I know that there are scenarios where this is hard to setup but I would recommend trying to avoid as many unstructured tasks as possible.

6 Likes