Automattic / kue

Kue is a priority job queue backed by redis, built for node.js.
http://automattic.github.io/kue
MIT License
9.46k stars 867 forks source link

Job stuck in queue when exception is thrown in the job start callback #1166

Open LouAdrien opened 6 years ago

LouAdrien commented 6 years ago

Hello, if any exeption arise in the callback of the job save method, and the main process is killed because of this exception, the all the jobs will be stuck in the "queued" state, and when restarting the application and connecting workers, these queued jobs won't be processed.

var job = queue.create('Some job', {
          title: 'Some title'
      }).attempts(3).save( function(err){
        //SOME CODE THROWING ERROR HERE
        cb(err)
      });

Any ideas how to fix this issue?

LouAdrien commented 6 years ago

Note : this will effectively solve the problem, but maybe I should not do that or I am not aware of the possible impact :

    // Recovered jobs stucks in inactive (queued state)
    queue.inactive(function(e,ids){
      ids.forEach( function( id ) {
        kue.Job.get( id, function( err, job ) {
          // Your application should check if job is a stuck one
          job.inactive();
        });
      });
    });
kakasal commented 6 years ago

Where is the Kue hell author? Reply this question