TraceResolveSRE Platform
MCP ServerAdmin
Back to CatalogPython / FastAPI

Python / FastAPI: RuntimeWarning: coroutine '...' was never awaited

RuntimeWarning: coroutine 'fetch_user_data' was never awaited Enable tracemalloc to get the object allocation traceback
Immediate Remediation
python
# Ensure async coroutine call is prefixed with await:
@app.get("/users/{user_id}")
async def get_user(user_id: str):
    # Fix: Added await keyword before async function call
    user_data = await fetch_user_data(user_id)
    return {"user": user_data}
Root Cause Analysis

An asynchronous function (defined with async def) was invoked synchronously without the await keyword, returning an unexecuted coroutine object instead of its return value.

Verification & Guardrails

  • If running in synchronous def endpoints, use asyncio.run(coroutine) or refactor endpoint to async def.
  • Run python with -X dev to get exact allocation line tracebacks.

Have a custom or uncategorized crash?

Run your trace through our in-memory client privacy sandbox for instant SRE remediation.

Open Diagnostic Studio