AnyIOStream.write leaks EndOfStream #1045
Replies: 1 comment
|
This looks like an httpcore backend-normalization gap rather than something httpx-ws should have to special-case. The current AnyIO backend already treats exc_map = {
TimeoutError: ReadTimeout,
anyio.BrokenResourceError: ReadError,
anyio.ClosedResourceError: ReadError,
anyio.EndOfStream: ReadError,
}but the corresponding That is inconsistent with the purpose of the network backend: callers of httpcore should see httpcore's So the minimal fix I would expect is to map: anyio.EndOfStream: WriteError,in I would not move this handling into httpx-ws: that would leak knowledge of httpcore's selected backend into a caller and would still leave other httpcore users exposed to the same backend-specific exception. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hi!
I'm facing an issue of
anyio.EndOfStreamexception slips through the exception map inAnyIOStream.writeinhttpcore/_backends/anyio.py. Based on this issue #808, it seems thereadmethod was fixed from the same error by addingEndOfStreamto the exception map in the read. Perhaps the write method could be fixed the same way by modifying this map?I'm not 100% sure if this is a httpcore issue or bug in the other dependencies though as I'm not too familiar with the topic. I use httpx-ws which uses httpcore underneath.
httpx-wswould catch this if it wasWriteErrorand notEndOfStreamerror so if theEndOfStreamerror was added to the exception map in httpcore I wouldn't get this issue. My guess is that this is casued by pinging, perhaps the ping writes to a closed stream or the ping closes the stream?Here is the traceback for the httpcore part:
In case it is relevant, here is what I did with
httpx-ws:The full traceback (this is in TaskGroup):
Feel free to point to httpx-ws in case this does not seem to be httpcore issue.
All reactions