# anyio.ClosedResourceError: ClosedResourceError

- **ID:** `python/starlette-streaming-response-disconnect`
- **Domain:** python
- **Category:** network_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Client disconnected while a StreamingResponse was still writing to the ASGI send channel.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 0.30.x | active | — | — |
| 0.36.x | active | — | — |

## Workarounds

1. **** (90% success)
   ```
   async for chunk in gen():\n    if await request.is_disconnected():\n        break\n    yield chunk
   ```
2. **** (88% success)
   ```
   try:\n    yield data\nexcept anyio.ClosedResourceError:\n    return
   ```

## Dead Ends

- **** — Does not prevent mid-stream client disconnects. (80% fail)
- **** — Channel is closed; further sends raise again. (85% fail)
