Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Throw exception when reading from AsyncBody after the channel closed (z…
…io#2399) (zio#2454) * Throw exception when reading from AsyncBody after the channel closed (zio#2399) Currently, when we call `Response.body.asStream`, we don't check to see if the corresponding response channel is open or not. If the channel has been closed and the user attempts to read the response body, it's possible for the body stream to hang (i.e never finish or throw an error), leading to the code hanging as illustrated in zio#2399. This behavior is undesirable since the user isn't aware of the channel closing (because we take care of that behind the scene), leading to the issue being hard to debug. This commit adds a check to `AsyncBodyReader.connect` so that we will throw an exception when the user attempts to read an unfinished response body from a closed channel. * fix: AsyncBodyReader emit failure when channel closes This is a bug which happened to me in CI: when the connect to the server closes, we must fail the response body stream so that the client doesn't hang forever trying to read from the stream.
- Loading branch information