hibiken/asynq · error
asynq
Error message
asynq: %w
What it means
GetTaskInfo returns an error wrapping ErrTaskNotFound when the queue exists but no task with the given id is found in it. The asynq: prefix marks the library as the source. Detect it with errors.Is(err, asynq.ErrTaskNotFound).
Solutions
- Confirm the task ID matches one returned by Enqueue and that the queue name is correct.
- Check task lifecycle: if retention was set, the task is removed after completion; treat ErrTaskNotFound as a normal post-completion outcome.
- List tasks (ListPendingTasks etc.) or use Inspector.GetTaskInfo on the correct queue to verify the ID exists.
Example fix
// before
info, err := inspector.GetTaskInfo("default", staleID)
// after
info, err := inspector.GetTaskInfo("default", taskID)
if errors.Is(err, asynq.ErrTaskNotFound) {
return nil, fmt.Errorf("task %s no longer exists (already completed or pruned)", taskID)
} Defensive patterns
Strategy: try-catch
Try / catch
info, err := inspector.GetTaskInfo(q, id)
if errors.Is(err, asynq.ErrTaskNotFound) {
// treat as normal: task completed/pruned or wrong id
} Prevention
- Set an appropriate retention when enqueuing if you need post-completion lookups
- Never cache task IDs across restarts without revalidation
- Match the queue name to the one used at Enqueue time
When it happens
Trigger: Calling Inspector.GetTaskInfo(queue, id) with an id for a task that was already processed and removed, never existed, or exists in a different queue; rdb.GetTaskInfo returns TaskNotFound wrapped at inspector.go:247.
Common situations: Looking up a task after it completed and was pruned (retention expired); using a task ID from another queue; caching a stale task ID across restarts.
Understand the failure class
Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.
Related errors
- task not found
- batch enqueue does not support group tasks
- batch enqueue does not support unique tasks
- redis connection is shared so the Inspector can't be closed…
- asynq: no scheduler entry found
AI-assisted analysis of hibiken/asynq@d135f1439b (2026-09-07).
Data as JSON: /api/errors/1930ffe1198f3f72.
Report an issue: GitHub.
Appendix: source
Thrown at inspector.go:247
return fmt.Errorf("%w: queue=%q", ErrQueueNotFound, queue)
}
if errors.IsQueueNotEmpty(err) {
return fmt.Errorf("%w: queue=%q", ErrQueueNotEmpty, queue)
}
return err
}
// GetTaskInfo retrieves task information given a task id and queue name.
//
// Returns an error wrapping ErrQueueNotFound if a queue with the given name doesn't exist.
// Returns an error wrapping ErrTaskNotFound if a task with the given id doesn't exist in the queue.
func (i *Inspector) GetTaskInfo(queue, id string) (*TaskInfo, error) {
info, err := i.rdb.GetTaskInfo(queue, id)
switch {
case errors.IsQueueNotFound(err):
return nil, fmt.Errorf("asynq: %w", ErrQueueNotFound)
case errors.IsTaskNotFound(err):
return nil, fmt.Errorf("asynq: %w", ErrTaskNotFound)
case err != nil:
return nil, fmt.Errorf("asynq: %w", err)
}
return newTaskInfo(info.Message, info.State, info.NextProcessAt, info.Result), nil
}
// ListOption specifies behavior of list operation.
type ListOption interface{}
// Internal list option representations.
type (
pageSizeOpt int
pageNumOpt int
)
type listOption struct {
pageSize int
pageNum intView on GitHub (pinned to d135f1439b)