You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
Test for statements instead of matching them if test is enough
precompile regex
This commit is contained in:
7
index.js
7
index.js
@@ -199,6 +199,9 @@ RedisClient.prototype.on_error = function (msg) {
|
||||
this.connection_gone("error");
|
||||
};
|
||||
|
||||
var noPasswordIsSet = /no password is set/;
|
||||
var loading = /LOADING/;
|
||||
|
||||
RedisClient.prototype.do_auth = function () {
|
||||
var self = this;
|
||||
|
||||
@@ -207,14 +210,14 @@ RedisClient.prototype.do_auth = function () {
|
||||
self.send_anyway = true;
|
||||
self.send_command("auth", [this.auth_pass], function (err, res) {
|
||||
if (err) {
|
||||
if (err.toString().match("LOADING")) {
|
||||
if (loading.test(err.message)) {
|
||||
// if redis is still loading the db, it will not authenticate and everything else will fail
|
||||
console.log("Redis still loading, trying to authenticate later");
|
||||
setTimeout(function () {
|
||||
self.do_auth();
|
||||
}, 2000); // TODO - magic number alert
|
||||
return;
|
||||
} else if (err.toString().match("no password is set")) {
|
||||
} else if (noPasswordIsSet.test(err.message)) {
|
||||
console.log("Warning: Redis server does not require a password, but a password was supplied.");
|
||||
err = null;
|
||||
res = "OK";
|
||||
|
Reference in New Issue
Block a user