Skip to content

Random exception from anyio #393

Closed
Closed

Description

@kangzhang

We upgraded our httpx library recently, which updated httpcore to 0.13.6.

httpx==0.18.2
  - certifi [required: Any, installed: 2021.5.30]
  - httpcore [required: >=0.13.3,<0.14.0, installed: 0.13.6]
    - anyio [required: ==3.*, installed: 3.3.0]
      - idna [required: >=2.8, installed: 2.10]
      - sniffio [required: >=1.1, installed: 1.2.0]
    - h11 [required: >=0.11,<0.13, installed: 0.12.0]
    - sniffio [required: ==1.*, installed: 1.2.0]
  - rfc3986 [required: >=1.3,<2, installed: 1.5.0]
  - sniffio [required: Any, installed: 1.2.0]

Since the update, we started getting random exceptions from httpcore/anyio. The error is usually about not awaited future returning BrokenResourceError exception.

Here is an example from our sentry log:

MESSAGE
Future exception was never retrieved
future: <Future finished exception=BrokenResourceError()>
EXCEPTION(most recent call first)

App Only

Full

Raw
ConnectionResetError: [Errno 104] Connection reset by peer
  File "asyncio/selector_events.py", line 848, in _read_ready__data_received
    data = self._sock.recv(self.max_size)
BrokenResourceError: null
  File "httpcore/_exceptions.py", line 8, in map_exceptions
    yield
  File "httpcore/_backends/anyio.py", line 154, in open_tcp_stream
    stream = await TLSStream.wrap(
  File "anyio/streams/tls.py", line 94, in wrap
    await wrapper._call_sslobject_method(ssl_object.do_handshake)
  File "anyio/streams/tls.py", line 109, in _call_sslobject_method
    data = await self.transport_stream.receive()
  File "anyio/_backends/_asyncio.py", line 1095, in receive
    raise self._protocol.exception

Our usage is simple and I audited and make sure all calls to httpx.AsyncClient were properly awaited. This never happened before the upgrade, with the old asyncio backend. (I saw that we made anyio the new default since ) #345

I'm wondering if you may know the possible causes of this symptom? (trying to get more signal to debug this)

Activity

  1. lovelydinosaur commented on Aug 12, 2021

    @lovelydinosaur
    Member

    Not sure, but first step would be to double check that httpcore is also up to date.

  2. kangzhang commented on Aug 13, 2021

    @kangzhang
    Author

    It seems there is another issue #382 filed with the same problem. We should discuss there maybe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions