TypeError: Cannot read property 'zcard' of null
at Queue.card (/Users/narain/Sites/integrity-automation/node_modules/kue/lib/kue.js:513:14)
at Queue.inactiveCount (/Users/narain/Sites/integrity-automation/node_modules/kue/lib/kue.js:616:17)
at _ (/Users/narain/Sites/integrity-automation/node_modules/kue/lib/http/routes/json.js:318:19)
at exports.stats (/Users/narain/Sites/integrity-automation/node_modules/kue/lib/http/routes/json.js:41:3)
at Layer.handle [as handle_request] (/Users/narain/Sites/integrity-automation/node_modules/express/lib/router/layer.js:95:5)
at next (/Users/narain/Sites/integrity-automation/node_modules/express/lib/router/route.js:131:13)
at /Users/narain/Sites/integrity-automation/node_modules/kue/lib/http/middleware/provides.js:11:36
at Layer.handle [as handle_request] (/Users/narain/Sites/integrity-automation/node_modules/express/lib/router/layer.js:95:5)
at next (/Users/narain/Sites/integrity-automation/node_modules/express/lib/router/route.js:131:13)
at Route.dispatch (/Users/narain/Sites/integrity-automation/node_modules/express/lib/router/route.js:112:3)
at Layer.handle [as handle_request] (/Users/narain/Sites/integrity-automation/node_modules/express/lib/router/layer.js:95:5)
at /Users/narain/Sites/integrity-automation/node_modules/express/lib/router/index.js:277:22
at Function.process_params (/Users/narain/Sites/integrity-automation/node_modules/express/lib/router/index.js:330:12)
at next (/Users/narain/Sites/integrity-automation/node_modules/express/lib/router/index.js:271:10)
at SendStream.error (/Users/narain/Sites/integrity-automation/node_modules/serve-static/index.js:120:7)
at emitOne (events.js:77:13)
at SendStream.emit (events.js:169:7)
at SendStream.error (/Users/narain/Sites/integrity-automation/node_modules/send/index.js:245:17)
at SendStream.onStatError (/Users/narain/Sites/integrity-automation/node_modules/send/index.js:356:12)
at next (/Users/narain/Sites/integrity-automation/node_modules/send/index.js:630:16)
at onstat (/Users/narain/Sites/integrity-automation/node_modules/send/index.js:619:14)
at FSReqWrap.oncomplete (fs.js:82:15)
I 'm getting this error pretty consistently under the following conditions:
- Have kui-ui dashboard open in a browser window
- perform graceful shutdown
I'm not certain if it is expected for Queue.client
to be null. If it is, then Queue.prototype.card
should first check if this.client
exists before calling this.client.card
. Same with Queue.prototype.cardByType
Here's my api route dashboard/stop
code (i.e., stops the process and flush the cache):
exports.stop = function(success, failure) {
let shutdown = new Promise((resolve, reject) => {
debug('shutting down queue');
queue.shutdown().then(() => {
client.flushdb(); // flushing the redis server
debug('redis is flushed');
resolve({success: true});
},
(err) => {
reject(err);
});
});
return shutdown;
};
Note: queue
is an instance of Kue
and client
is of redis
:
let queue = require('kue').createQueue({prefix: '', redis: config.get('redisurl'), jobEvents: false});
let client = require('redis').createClient({
'url': config.get('redis') // redis-url
});
Same question (issue) have also been raised on github:
And have no response yet..
Any Idea/thoughts! How to get this fix..?
Issue was causing because of
Queue.prototype.shutdown
implementation destroy client (i.e., redis) instance that's why when it callQueue.prototype.card
andQueue.prototype.cardByType
then it throws that error..As for as my aim was to somehow stop (pause) the queue process and then resume it again.. so i have done something like that instead of using
Queue.prototype.shutdown
i have rather usedWorker.prototype.shutdown
which pauses the worker's (process)..queue.js
(sample):serverRunner.js
(sample):That's it!
Hope this help others!!
Cheers.