-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How do I know if I provided an incorrect password? #164
Comments
Yes, we may emit an event when the password is wrong. May be |
So for the workaround to work:
redisInstance.on("connect", function () {
redisInstance.auth("pawsword", function (err, res) {
if (err) {
console.error(err);
redisInstance.disconnect()
process.exit();
}
})
}); But I'd appreciate a way to catch the initial built-in auth failure. redisInstance.on("error",function(authError){}) ^would be the way to go imho |
|
Well, I'm on this camp that prefers when errors have to be handled ;) but ok. |
new Redis(options)
with options.password being incorrect or missing, doesn't throw (not surprising, AUTH is async) and it doesn't emitend
norclose
, norerror
.How do I know if the AUTH command that happens in the background failed?
[edit]
It works if I call
.auth
myself, but otherwise, the error is swallowed. I even found one location which might be responsible for swallowing it: https://github.com/luin/ioredis/blob/master/lib/redis.js#L124But switching to lazyConnect and connecting on my own would also resolve happily without reporting auth issues, so that's not all there is to it.
[one more edit]
Unfortunately, calling
.auth
on my own is not possible, because a "Ready check" is made, and it fails because auth was not made yet... So no workaround here.The text was updated successfully, but these errors were encountered: