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 is swallowing errors from Redis #1197

Open Gappa88 opened 6 years ago

Gappa88 commented 6 years ago

hi,

I have a Nodejs (v8.11) application that writes data to Redis (v4.0.10) via Kue (v0.11.6). I sat a maxmemory limit to Redis and when I reach that limit Kue doesn't properly handle errors from redis.

The bugged function is this in detail here.

this.set('data', json, function() {   // missing return parameters (err, foo)
    // state
    this.state(this._state, fn);
  }.bind(this));

where the callback function doesn't handle return parameters.

This bug is swallowing important Redis' errors like

OOM command not allowed when used memory > 'maxmemory'

does anyone have a patch that solve this and allow me to take errors back to the main function caller in order to handle it?

can this snippet solve cleanly the problem, @behrad?

this.set('data', json, function (err) { // <=== err added

    if (err) return fn(err);   // <=== return the error
    // state
    this.state(this._state, fn);
  }.bind(this));