Skip to content

Commit

Permalink
Bind this to done on error (#1)
Browse files Browse the repository at this point in the history
Fixes

```
TypeError: Cannot read property 'emit' of undefined
```

When `restore: true` in the `createQueue()` options object.

This was happening when an error was being passed, as the binding wasn't occuring in that instance.  When I was able to output the error that was occurring, it was:

```
Error: All keys in the pipeline should belong to the same slot
    at Pipeline.exec (/data/node_modules/ioredis/lib/pipeline.js:235:21)
    at Pipeline.pipeline.exec (/data/node_modules/ioredis/lib/transaction.js:34:26)
    at Queue.<anonymous> (/data/node_modules/kue-scheduler/index.js:1428:14)
From previous event:
    at new Pipeline (/data/node_modules/ioredis/lib/pipeline.js:30:18)
    at Cluster.redis.multi (/data/node_modules/ioredis/lib/transaction.js:24:20)
    at Queue.<anonymous> (/data/node_modules/kue-scheduler/index.js:1420:32)
    at runCallback (timers.js:800:20)
    at tryOnImmediate (timers.js:762:5)
    at processImmediate [as _immediateCallback] (timers.js:733:5)
```
  • Loading branch information
ggutenberg committed Apr 2, 2019
1 parent af47b9a commit ef5cb31
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Expand Up @@ -1467,7 +1467,7 @@ Queue.prototype.restore = function (done) {
this._getAllJobData(function (error, data) {
//backoff if error throw
if (error) {
done(error);
done.bind(this, error);
}

//restore job schedules
Expand Down

0 comments on commit ef5cb31

Please sign in to comment.