diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..8896306 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,30 @@ +{ + "extends": ["react-app", "exaptive"], + "rules": { + "comma-dangle": [ + "error", + { + "arrays": "always-multiline", + "objects": "always-multiline", + "imports": "always-multiline", + "exports": "always-multiline", + "functions": "ignore" + } + ], + + "space-before-function-paren": [ + "error", + { + "anonymous": "never", + "named": "never", + "asyncArrow": "always" + } + ], + + "class-methods-use-this": 0, + + "indent": 0, + + "no-console": "error" + } +} diff --git a/celery.js b/celery.js index 95fd635..d290e31 100644 --- a/celery.js +++ b/celery.js @@ -122,16 +122,20 @@ function RedisBackend(conf) { var backend_ex = self.redis.duplicate(); + backend_ex.on('error', function(err) { + self.emit('error', err); + }); + self.redis.on('error', function(err) { self.emit('error', err); }); self.redis.on('end', function() { self.emit('end'); + backend_ex.quit(); }); self.disconnect = function() { - backend_ex.quit(); self.redis.quit(); }; @@ -145,7 +149,12 @@ function RedisBackend(conf) { debug('Backend connected...'); // on redis result.. self.redis.on('pmessage', function(pattern, channel, data) { - backend_ex.expire(channel, conf.TASK_RESULT_EXPIRES / 1000); + try { + backend_ex.expire(channel, conf.TASK_RESULT_EXPIRES / 1000); + } catch(e) { + console.log('node_celery backend expire failure', e); + self.emit('error', e); + } var message = JSON.parse(data); var taskid = channel.slice(key_prefix.length); if (self.results.hasOwnProperty(taskid)) {