Shadcn Job Queue Table
Background jobs as they run: progress, attempts and duration update live, failures retry on their own with backoff, and any job with errors expands to show what went wrong before you retry or cancel it.
$ npx shadcn add https://www.shad-table.dev/r/job-queue-table.json2 of 2 workers busy · 3 waiting · 1 failed
| Errors | Job | Status | Progress | Attempts | Duration | Actions |
|---|---|---|---|---|---|---|
Send welcome emailsemails · job_8f2a | Succeeded | 100% · 1,200 / 1,200 | 1 / 3 | 30s | ||
Sync Stripe customersbilling · job_3c71 | Failed | 30% · 1,260 / 4,200 | 3 / 3 | 26s | ||
Export invoices (Q3)exports · job_51d0 | Running | 26% · 900 / 3,400 | 1 / 3 | 6s | ||
Resize product imagesmedia · job_a904 | Running | 13% · 120 / 860 | 1 / 3 | 2s | ||
Generate payout reportbilling · job_c2e8 | Queued | Waiting · 240 items | 0 / 3 | — | ||
Rebuild search indexsearch · job_77b3 | Queued | Waiting · 5,000 items | 0 / 3 | — | ||
Send trial remindersemails · job_e015 | Queued | Waiting · 300 items | 0 / 3 | — | ||
Purge expired sessionssearch · job_0d6c | Canceled | 41% · 7,400 / 18,000 | 1 / 3 | 8s |
How it works
1.A job is its attempts
Each job keeps a list of attempts with their start, end, how far they got and the error, if any. Status, the attempts count and the duration are all read from that list, and so is the error history in the expanded row. A real app fills it from whatever the workers report.
interface Attempt {number: numberstartedAt: numberendedAt?: numberprocessed?: numbererror?: { code: string; message: string; trace: string[] }}
2.Failures retry on their own, with backoff
A failed attempt puts the job in Retrying with a countdown (2s, then 4s, then 8s) until it runs out of attempts, and only then is it Failed. Retrying by hand puts it back in the queue with one more attempt allowed. At most two jobs run at once; the one that has waited longest starts next.
return attempt < job.maxAttempts? { ...job, status: 'retrying', retryAt: now + backoff(attempt) }: { ...job, status: 'failed' }
3.Rows with errors expand to their history
getRowCanExpand allows expanding only rows that have a failed attempt, including jobs that later succeeded. The detail lists every attempt, newest first, with the error code, message and stack trace, so it is clear whether a retry is worth it.
getRowCanExpand: (row) => hasErrors(row.original),autoResetExpanded: false,
4.Live data without losing your place
The queue updates five times a second, and TanStack resets expanded rows whenever the data changes unless told otherwise. getRowId keys rows by job id and autoResetExpanded: false keeps open rows open. The filter array is memoized so a tick does not count as a filter change.
getRowId: (job) => job.id,autoResetExpanded: false,autoResetPageIndex: false,
5.One clock for the server and the browser
Durations come from a demo clock that starts at 0 on both the server and the browser, so the first render matches and there is no hydration warning. In your app, pass the server time the data was read at as now, and tick it forward on the client.
const start = (): Queue => ({ now: 0, jobs: seedJobs() })setQueue((q) => ({ now: q.now + TICK, jobs: tick(q.jobs, q.now + TICK, TICK) }))