You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using ioredis in Heroku using RedisToGo add-on, I get this error:
Unhandled rejection ReplyError: ERR invalid DB index
at ReplyParser._parseResult (/app/node_modules/ioredis/lib/parsers/javascript.js:56:14)
at ReplyParser.execute (/app/node_modules/ioredis/lib/parsers/javascript.js:174:20)
at Socket.<anonymous> (/app/node_modules/ioredis/lib/redis/event_handler.js:88:22)
at Socket.emit (events.js:107:17)
at readableAddChunk (_stream_readable.js:163:16)
at Socket.Readable.push (_stream_readable.js:126:10)
at TCP.onread (net.js:538:20)
Everything works fine on my local machine(OS X) and local redis. I'm testing this with free plan in RedisToGo.
I'm initializing ioredis(version 1.5.0) like this:
varredis=newRedis(process.env.REDIS_URL,{retryStrategy: function(times){// Make reconnecting a bit more relaxed compared to defaultvardelay=Math.min(times*100,4000);returndelay;}});
REDIS_URL in heroku is in format: redis://redistogo:<secret>@<secret>.redistogo.com:<port>/.
REDIS_URL in local is: redis://127.0.0.1:6379
Do you have ideas of how to fix this? Redis works apparently correctly but my logs fill up with those exceptions and in general I'd like to get this resolved.
By setting the database to 0 in the url: redis://redistogo:<secret>@<secret>.redistogo.com:<port>/0 the issue goes away.
Reacted by James Knight, Ricardo Pedrosa, zackyangzinc, Leandro Curioso, wansj, Miguel Angel, Adalberto Pompolo, Robert Molina, Cesar Augusto, Drilliak and 6 more
This might be an bug in parsing urls with trailing slash. Quote from RedisToGo support:
Just wanted to send you a bit more information, as I did some digging into the driver code and I have found the source of the issue. Here is some sample code from the node shell that should explain things:
Looking through the documentation for the driver they list a trailing slash as a valid URL, but in this driver it is not handled correctly. Here is the example in the docs:
Activity
kimmobrunfeldt commentedon Jun 16, 2015
By setting the database to 0 in the url:
redis://redistogo:<secret>@<secret>.redistogo.com:<port>/0the issue goes away.kimmobrunfeldt commentedon Jun 16, 2015
This might be an bug in parsing urls with trailing slash. Quote from RedisToGo support:
nakulgan commentedon Jun 16, 2015
Any idea what Version of Redis they're running at redistogo.com?
SELECT ''seems to be valid on >Redis 2.4 and defaults to 0.luin commentedon Jun 16, 2015
It's a bug that getting a NaN db when the pathname is empty. Fixed in 1.5.1. Thanks for pointing it out.
Strip trailing slash from URL provided in `sails.config.session.url`
theronic commentedon Apr 30, 2020
This still happens on Heroku using v4.16.3. Adding /0 to the end of the Redis URL makes it go away.