lykmapipo / kue-scheduler

A job scheduler utility for kue, backed by redis and built for node.js
246 stars 47 forks source link

Redis error after completed job #81

Closed ulisesbocchio closed 7 years ago

ulisesbocchio commented 7 years ago

This app:

console.log('worker');
const Kue = require('kue-scheduler');

var queue = Kue.createQueue({
  prefix: 'kue2_',
  redis: {
    port: 6379,
    host: 'localhost',
    options: {
    }
  }
});

queue.clear((error, response) => {

    var job = queue
                .createJob('unique', { timezone: 'America/Los_Angeles' })
                .attempts(3)
                .priority('normal')
                .unique('unique_every');

    queue.every('*/5 * * * * *', job);

    queue.on( 'error', function( err ) {
      console.log( 'Oops... ', err );
    });

    var name = "blah";

    queue.process('unique', function(job, ctx, done) {
        console.log('running...', name);
        setTimeout(() => {
            console.log('completing...', name);
            done();
        }, 1000);
    });

});

starts just fine and runs the first job but then when it's time to run a second one... it fails with some error that keeps going for ever... this is an excerpt of the output:

worker
running... blah
completing... blah
Oops...  { ReplyError
    at parseError (/Users/boccs002/js/kue-scheduler/node_modules/redis-parser/lib/parser.js:181:12)
    at parseType (/Users/boccs002/js/kue-scheduler/node_modules/redis-parser/lib/parser.js:291:14)
  command: 'BLPOP',
  args: [ 'kue2_:unique:jobs', 0 ],
  code: 'WRONGTYPE' }
Oops...  { ReplyError
    at parseError (/Users/boccs002/js/kue-scheduler/node_modules/redis-parser/lib/parser.js:181:12)
    at parseType (/Users/boccs002/js/kue-scheduler/node_modules/redis-parser/lib/parser.js:291:14)
  command: 'BLPOP',
  args: [ 'kue2_:unique:jobs', 0 ],
  code: 'WRONGTYPE' }
Oops...  { ReplyError
    at parseError (/Users/boccs002/js/kue-scheduler/node_modules/redis-parser/lib/parser.js:181:12)
    at parseType (/Users/boccs002/js/kue-scheduler/node_modules/redis-parser/lib/parser.js:291:14)
  command: 'BLPOP',
  args: [ 'kue2_:unique:jobs', 0 ],
  code: 'WRONGTYPE' }
Oops...  { ReplyError
    at parseError (/Users/boccs002/js/kue-scheduler/node_modules/redis-parser/lib/parser.js:181:12)
    at parseType (/Users/boccs002/js/kue-scheduler/node_modules/redis-parser/lib/parser.js:291:14)
  command: 'BLPOP',
  args: [ 'kue2_:unique:jobs', 0 ],
  code: 'WRONGTYPE' }
Oops...  { ReplyError
    at parseError (/Users/boccs002/js/kue-scheduler/node_modules/redis-parser/lib/parser.js:181:12)
    at parseType (/Users/boccs002/js/kue-scheduler/node_modules/redis-parser/lib/parser.js:291:14)
  command: 'BLPOP',
  args: [ 'kue2_:unique:jobs', 0 ],
  code: 'WRONGTYPE' }

any clues?

ulisesbocchio commented 7 years ago

BTW, the actual code that creates the job and schedules it is inside queue.clear((error, response) => {...}) because without that the same error shows immediately as soon as I start the script.

ulisesbocchio commented 7 years ago

very weird, I think unique cannot be used as the job name, I changed it to something else and it worked as expected. It should probably be documented.

lykmapipo commented 7 years ago

Sure.

@ulisesbocchio I will appreciate the update on the docs.