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

kue.Job.remove() fails - getting TypeError in "node_modules/kue/lib/redis.js:133" #1206

Closed IuriiD closed 5 years ago

IuriiD commented 5 years ago

Hi guys! Sorry, I'm a newbie with kue and with coding in general so would be very thankfull if someone could give me advice (maybe I'm doing some stupid mistake? Have been struggling with this issue for several hours already). So, when executing the following simple code:

const kue = require('kue');

kue.Job.remove(34, (err) => {
  if (err) console.log(`Err: ${err}`);
});

(where 34 is the id of job I see in http://127.0.0.1:3050/ or can get as described here)

I am getting an error:

/home/dev33/yorik/dev/msbf/node_modules/kue/lib/redis.js:133
  return exports._client || (exports._client = exports.createClient());
                                                       ^
TypeError: exports.createClient is not a function
    at Object.exports.client (/home/dev33/yorik/dev/msbf/node_modules/kue/lib/redis.js:133:56)
    at Function.exports.get (/home/dev33/yorik/dev/msbf/node_modules/kue/lib/queue/job.js:169:22)
    at Function.exports.remove (/home/dev33/yorik/dev/msbf/node_modules/kue/lib/queue/job.js:260:11)
    at Object.<anonymous> (/home/dev33/yorik/dev/msbf/helpers/clearQueueForUser.js:9:9)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Function.Module.runMain (module.js:693:10)

What can be the reason? Thanks in advance.

IuriiD commented 5 years ago

Hmm... looks like it was a silly evening mistake ;) With a adding 1 line of code (see below) it works:

const kue = require('kue');
const jobs = kue.createQueue();

kue.Job.remove(39, (err) => {
  if (err) console.log(err);
});