Automattic / Automattic/kue

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

Open
#1,017 6 comments 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
9.4k
Forks
858
PR merge metrics
No merged PRs in 30d

Description

````
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.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in lib/redis.js at lines 114 and 119-121, then reproduce the queue setup using a Redis Unix socket. Verify that connecting through the socket no longer calls select with an invalid database index and no unhandled ERR invalid DB index exception occurs.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js, redis
Domain
backend, databases
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.