# Task exception was never retrieved
future: <Task finished name='Task-5' coro=<fetch() done, defined at app.py:42> exception=ValueError('bad payload')>

- **ID:** `python/asyncio-task-exception-was-never-retrieved`
- **Domain:** python
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

A task created with asyncio.create_task() raised an exception, but nobody awaited the task or called task.exception(), so the exception is logged as a warning at garbage collection.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.8 | active | — | — |
| 3.9 | active | — | — |
| 3.10 | active | — | — |
| 3.11 | active | — | — |
| 3.12 | active | — | — |

## Workarounds

1. **** (90% success)
   ```
   tasks = [asyncio.create_task(fetch(u)) for u in urls]
results = await asyncio.gather(*tasks, return_exceptions=True)
for r in results:
    if isinstance(r, Exception):
        logging.exception('task failed', exc_info=r)
   ```
2. **** (87% success)
   ```
   def _on_done(t: asyncio.Task):
    if not t.cancelled() and t.exception():
        logging.error('task error', exc_info=t.exception())

t = asyncio.create_task(fetch(u))
t.add_done_callback(_on_done)
   ```

## Dead Ends

- **** — Hides the symptom but the task still fails silently and the error is lost. (85% fail)
- **** — Swallows real errors and produces no diagnostic; debugging becomes impossible. (80% fail)
