-
Notifications
You must be signed in to change notification settings - Fork 411
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 (#…
…2399) (#2454) * Throw exception when reading from AsyncBody after the channel closed (#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 #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
Showing
3 changed files
with
43 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters