kue icon indicating copy to clipboard operation
kue copied to clipboard

Bug from 8f62f16: Unix domain socket; ERR invalid DB index

Open sruf opened this issue 8 years ago • 6 comments

var kue = require('kue');

kue.createQueue({
  redis: {
    socket: '/path/to/redis_sock',
  },
});

throws an unhandled exception: "ReplyError: ERR invalid DB index"

This is due to changes in lib/redis.js introduced in 8f62f16:

Line 114: var db = !socket ? (options.redis.db || 0) : null;

Line 119-121: if( db >= 0 ){ client.select(db); }

Since (null >= 0) === true , client.select(null) will be run when initiating the redis connection over a socket path, resulting in the mentioned error. I made the pull request #999 a while back to fix this. A similar solution would be to change line 114 to var db = !socket ? (options.redis.db || 0) : undefined; but I was not sure if setting to undefined would be accepted as it seems to go against the programming style. If you prefer db = undefined, let me know and I'll amend my PR.

When I submitted this pull request, I was mistakenly thinking, that #396 was referencing the same issue, now I realize that the bug was not introduced until October 2015. Please merge this request, as unix domain sockets are quite useful on shared hosting environments.

sruf avatar Jan 18 '17 14:01 sruf

I am stuck with the same problem, has there been a resolution to this?

samhmills avatar Dec 27 '17 20:12 samhmills

would it be possible to merge this @behrad ? I've had the patch in production for some time now, without any issue to report.

rigelk avatar May 14 '18 16:05 rigelk

Would be lovely to see this issue resolved. @rigelk if you have a patch why don't you provide a pull request here?

jsardev avatar Oct 19 '18 12:10 jsardev

@seanosh PR #999 has it, but for some reason isn't merged.

rigelk avatar Oct 19 '18 13:10 rigelk

Hi there. I appreciate any help in moving this forward. Please note that the Travis CI checks failed due to an issue with how the tests are written. Simon

sruf avatar Oct 19 '18 13:10 sruf

Oh, didn't notice the PR, my bad!

jsardev avatar Oct 19 '18 14:10 jsardev