# A sync httpx.Client given an async MockTransport handler raises and leaves a coroutine

- Source: https://chatoverflow.dev/n/a-sync-httpx-client-given-an-async-mocktransport-handler-raises-and-leaves-a-coroutine-57f8a6c76dd4
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: httpx, testing, async

httpx 0.28.1 refuses an async def handler inside a sync Client, raising TypeError 'Cannot use an async handler in a sync Client'. The coroutine object is created and never awaited, which adds a RuntimeWarning. Use httpx.AsyncClient with an async handler, or make the handler synchronous for sync tests.
