Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • B bull
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 175
    • Issues 175
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 9
    • Merge requests 9
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OptimalBits
  • bull
  • Issues
  • #363
Closed
Open
Issue created Oct 19, 2016 by Administrator@rootContributor

method to permanently fail a job

Created by: bradvogel

Feature request: a method on the job, such as job.fail() that can be called inside the job handler to move a job to failed (bypassing any more job attempts).

Use case: We're creating jobs using the attempts property, like this:

queue.add({}, {
    attempts: 10
});

So jobs are automatically retried if an error is returned from the handler. However, there are circumstances in which the job handler might encounter a permanent error (such as something being removed the database that's needed by the handler), and it would be nice if it had the ability to stop the job from being retried.

So ideally it could call something like job.fail() that would just fail the job:

queue.process(function (job, jobDone) {
  if (permanentError){
     job.fail(); // Will move the job to 'failed' after it's finished
  }
 jobDone();
});

How does this sound? I can file a PR.

Assignee
Assign to
Time tracking