···11+# Task Queue
22+33+> Background job processing with retries and timeouts shouldn't require a framework.
44+55+## The Problem
66+77+Background jobs are everywhere: sending emails, processing images, syncing data. Each job needs:
88+- **Retry logic** for transient failures
99+- **Timeouts** so jobs don't run forever
1010+- **Error handling** with context preserved
1111+- **Testability** - easy to mock dependencies
1212+1313+In vanilla TypeScript, you end up with manual Promise tracking, scattered try/catch blocks, and code that's impossible to test without real dependencies.
1414+1515+## Run Both Versions
1616+1717+```bash
1818+bun run examples/task-queue/without-purus.ts
1919+bun run examples/task-queue/with-purus.ts
2020+```
2121+2222+## Without purus
2323+2424+See `without-purus.ts` - realistic code showing:
2525+- Manual Promise tracking for workers
2626+- `Promise.race` for timeout (doesn't cancel the job!)
2727+- Lost error context after retries fail
2828+- Hard to test - dependencies are hardcoded
2929+3030+## With purus
3131+3232+See `with-purus.ts` - same functionality with:
3333+- `fork`/`join` for fiber-based workers
3434+- `timeout(30000)` actually cancels the job
3535+- `catchAll` preserves error context
3636+- `provide(mockEnv)` makes testing trivial
3737+3838+## Key Takeaways
3939+4040+- **Fibers > Promises** → Real cancellation, not just ignoring results
4141+- **Composable timeouts** → `timeout()` is just another combinator
4242+- **Error context preserved** → `catchAll` sees the original error
4343+- **Dependency injection** → `provide()` makes testing trivial