Skip to content
Get started
Get started
Querying Jobs: State, Counts and Results
guide · queue

Asking the queue what it holds.

Dashboards, health checks and debugging all come down to the same questions: what is in there, what state is it in, and what did that one job actually return.

// One job
const job = await queue.getJob('job-id');
const state = await queue.getJobState('job-id');
// 'waiting' | 'prioritized' | 'delayed' | 'active' | 'completed'
// | 'failed' | 'waiting-children' | 'unknown'
// Counts per state
const counts = await queue.getJobCountsAsync();
// { waiting, prioritized, active, completed, failed, delayed,
// 'waiting-children', paused }
// Lists, filtered by state
const failed = await queue.getJobsAsync({ state: 'failed', start: 0, end: 50 });
// Exhaustive traversal; TCP mode transparently drains consecutive pages
const everyFailedJob = await queue.getFailedAsync(0, -1);

Most read methods come in two flavors: a sync version that only works in embedded mode (getJobCounts(), getJobs(), getCountsPerPriority(), count(), isPaused()) and an async version that works in both modes (getJobCountsAsync(), getJobsAsync(), getCountsPerPriorityAsync(), countAsync(), isPausedAsync()). Prefer the async ones unless you know you’re embedded.

Jobs returned by getJob() and getJobsAsync() reflect the authoritative broker generation in both modes. In particular, attemptsMade, attemptsStarted, stalledCounter, progress, priority, processing/completion timestamps, and their toJSON() / asJSON() representations are not reset by the TCP query proxy.

Per-state shortcuts:

// Sync (embedded only): getWaiting, getActive, getCompleted, getFailed, getDelayed
const waiting = queue.getWaiting(0, 10);
// Async (both modes): same names + Async
const failed = await queue.getFailedAsync(0, 10);
// Counts (async, both modes)
const failedCount = await queue.getFailedCount();
// also: getWaitingCount, getActiveCount, getCompletedCount, getDelayedCount
// BullMQ-compatible extras
const prioritized = await queue.getPrioritized(0, 10); // jobs with priority > 0
const waitingChildren = await queue.getJobsAsync({
state: 'waiting-children', start: 0, end: 10,
});

Per-state shortcuts are available in TypeScript and Python; in PHP, Go, Rust, and Elixir use getJobs with a state filter.

getPrioritized() and getWaitingChildren() work in embedded and TCP modes. Both use the asynchronous job-query path; waiting children are selected through the dedicated state rather than inferred from job data.

On the Bun client, end: -1 is an explicit exhaustive read for getJobs, getJobsAsync, every sync/async state shortcut, getPrioritized, and getWaitingChildren. TCP mode requests 1,000-row pages until exhaustion and removes duplicate IDs defensively; a finite end still denotes the exclusive end of one page. getJobs[Async]({ asc: false }) reverses the stable createdAt/job-id order before that pagination. Because the broker protocol uses numeric offsets rather than a snapshot cursor, concurrent inserts/removals can shift later pages. Pause mutation or reconcile IDs in application code when a stable snapshot is required.

Jobs that exhaust their retries move to the dead letter queue (DLQ, a holding area for permanently failed jobs) but remain visible: they are counted by failed, returned by getJob(id), and listed by getFailed().

Queue APICreate a queue in embedded or TCP mode
Adding Jobsadd, addBulk, priorities, delays, durability
Deduplication and Idempotent Job AddsIdempotent adds, dedup keys, custom job ids
Queue Control and MaintenancePause, drain, obliterate, clean and repair
Progress, Job Logs and DependenciesProgress, per-job logs and dependencies
Queue Rate Limiting and Global ConcurrencyRate limits and global concurrency caps
Job Schedulers from the QueueNamed repeatable schedules from the queue
DLQ Operations from the Queue ObjectFailed-job operations from the Queue object
Workers, Stats and Metrics from the QueueRegistered workers, stats and metrics windows
Namespaces, Auto-Batching and Store-and-ForwardNamespaces, auto-batching, store-and-forward
JobOptions ReferenceEvery JobOptions field, with defaults