[GH-ISSUE #221] [FEATURE REQUEST] Allow handlers to fail a task permanently (no retry) #2106

Closed
opened 2026-03-15 19:11:16 +03:00 by kerem · 2 comments
Owner

Originally created by @bojanz on GitHub (Jan 6, 2021).
Original GitHub issue: https://github.com/hibiken/asynq/issues/221

Originally assigned to: @hibiken on GitHub.

Is your feature request related to a problem? Please describe.
Asynq supports automatically retrying tasks. In some cases, it is obvious to the handler that a task can't ever be completed successfully. The handler currently has two ways to handle this:

  • Return an error, and go through the next N retries.
  • Return nil and stop processing.

Returning nil has the downside of not keeping the task "dead", so it becomes invisible to the CLI and the future web UI.

Describe the solution you'd like
I'd like to be able to return an error such as asynq.NoRetryError(msg) which would stop execution and mark the task as dead.

Describe alternatives you've considered
Returning nil and flipping a "permanently failed" boolean on the object being processed works as an alternative. This feature request is a "nice to have", but feels reasonable for a queue to support.

Originally created by @bojanz on GitHub (Jan 6, 2021). Original GitHub issue: https://github.com/hibiken/asynq/issues/221 Originally assigned to: @hibiken on GitHub. **Is your feature request related to a problem? Please describe.** Asynq supports automatically retrying tasks. In some cases, it is obvious to the handler that a task can't ever be completed successfully. The handler currently has two ways to handle this: - Return an error, and go through the next N retries. - Return nil and stop processing. Returning nil has the downside of not keeping the task "dead", so it becomes invisible to the CLI and the future web UI. **Describe the solution you'd like** I'd like to be able to return an error such as asynq.NoRetryError(msg) which would stop execution and mark the task as dead. **Describe alternatives you've considered** Returning nil and flipping a "permanently failed" boolean on the object being processed works as an alternative. This feature request is a "nice to have", but feels reasonable for a queue to support.
kerem 2026-03-15 19:11:16 +03:00
Author
Owner

@hibiken commented on GitHub (Jan 6, 2021):

@bojanz Thank you for opening this issue, this is definitely much-needed feature.

The solution you suggested sounds reasonable to me. Handler can return some sentinel error type to indicate that the task doesn't need to be retried.
I'll include this change in the next version release (should be in a week or two if all goes well).

<!-- gh-comment-id:755777687 --> @hibiken commented on GitHub (Jan 6, 2021): @bojanz Thank you for opening this issue, this is definitely much-needed feature. The solution you suggested sounds reasonable to me. `Handler` can return some sentinel error type to indicate that the task doesn't need to be retried. I'll include this change in the next version release (should be in a week or two if all goes well).
Author
Owner

@hibiken commented on GitHub (Jan 14, 2021):

Closed via #226

<!-- gh-comment-id:760241083 --> @hibiken commented on GitHub (Jan 14, 2021): Closed via #226
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/asynq#2106
No description provided.