Task Exception Was Never Retrieved

Task exception was never retrieved: future: <Task finished ... exception=ValueError('...')>

Quick Answer

An asyncio task raised an exception but you never awaited it. Always await tasks or call task.result() to retrieve exceptions.

Why This Happens

When a fire-and-forget task raises an exception, Python logs a warning because nothing is waiting for the result. This can hide bugs in your async code.

The Problem

async def risky():
    raise ValueError('error')

async def main():
    asyncio.create_task(risky())  # Exception lost!
    await asyncio.sleep(1)

The Fix

async def risky():
    raise ValueError('error')

async def main():
    task = asyncio.create_task(risky())
    try:
        await task
    except ValueError as e:
        print(f'Caught: {e}')

Step-by-Step Fix

  1. 1

    Always await tasks

    Store and await task references.

  2. 2

    Use asyncio.gather()

    Run and await multiple tasks together.

  3. 3

    Add error callbacks

    Use task.add_done_callback() for fire-and-forget tasks.

Bugsly catches this automatically

Bugsly's AI analyzes this error pattern in real-time, explains what went wrong in plain English, and suggests the exact fix — before your users even report it.

Try Bugsly free