/fixes #2297 /claim #2297
As I mentioned in https://github.com/zio/zio-http/pull/2402#issuecomment-2315114560, the problem with this issue (as well as what #2402 was trying to resolve) is that in the case of an ultra-fast producer, the ZStream buffer queue becomes full, which ends up blocking Netty’s event loop. Since Netty’s event loop is… event-based, once a connection is is closed, reading from the channel will keep returning messages until all of them have been consumed.
The solution here is to use an unbounded queue to construct the ZStream. By using an unbounded queue, we no longer block Netty’s event loop in cases that the buffer becomes full. This means that when the connection is interrupted we can shutdown the queue / ZStream via callback.fail(cause).
PS: While it might sound dangerous not to have a backpressure mechanism on the ZStream, in reality the backpressure needs to be applied on Netty’s side via Netty’s config. Otherwise, even if the ZStream has backpressure, Netty’s queues will still be filled and memory issues will arise. See https://github.com/zio/zio-http/pull/2402#issuecomment-2315114560 for more info
kyri-petrou
@kyri-petrou
ZIO
@ZIO