Server streaming handler not cancelled on client disconnect

Issue:

When a client disconnects during a server streaming RPC, the async generator is never closed. The generator continues yielding indefinitely and each yield produces a failed socket write and an asyncio warning:

WARNING:asyncio:socket.send() raised exception

Expected (or at least what I think should be happening):

the framework should monitor receive() for http.disconnect and call aclose() or something along those lines.

Reproduce:

  1. Create server streaming endpoint a generator that yields indefinitely (e.g. a watch rpc)
  2. Connect to it with a client
  3. Kill the client
  4. Observe the server logging the socket.send() raised exception indefinitely

Workaround:

ASGI middleware that queues receive()