73
job queue
Work that must not live inside the request: mail, thumbnails, webhooks you send. Durable, retried, idempotent.
What is job queue?
A job queue stores work for a worker to run later. The HTTP request enqueues and returns. The worker retries with backoff. If the process dies, the job remains.
Why does job queue matter when vibe coding?
Models `await sendEmail()` inside the POST. The user stares at a spinner, and a timeout loses the send. Name the queue or the request owns work it cannot finish.
How do you do job queue?
If it can be slow, fail, or be retried, it is a job. The request writes the row and enqueues. The worker is idempotent. Failed jobs are visible, not swallowed.
How do you ask a model for job queue?
Do not do (slow work) in the request. Enqueue a job. The handler returns after the enqueue. The worker must be idempotent and retry with backoff. Record failures.
What goes wrong with job queue?
`setTimeout` or an in-memory array. That dies with the process. A queue is durable.