Skip to content

Commit

Permalink
fix: reconnect when ready check failed
Browse files Browse the repository at this point in the history
  • Loading branch information
luin committed May 7, 2016
1 parent b1c761c commit 3561fab
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
6 changes: 2 additions & 4 deletions lib/redis/event_handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,8 @@ exports.connectHandler = function (self) {
self._readyCheck(function (err, info) {
if (err) {
self.flushQueue(new Error('Ready check failed: ' + err.message));
if (!self.condition.auth && err.message.split(' ')[0] === 'NOAUTH') {
self.silentEmit('error', err);
self.disconnect(true);
}
self.silentEmit('error', err);
self.disconnect(true);
} else {
self.serverInfo = info;
if (self.connector.check(info)) {
Expand Down
16 changes: 16 additions & 0 deletions test/functional/ready_check.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,20 @@ describe('ready_check', function () {
});
redis.connect();
});

it('should reconnect when info return a error', function (done) {
var redis = new Redis({
lazyConnect: true,
retryStrategy: function () {
done();
return;
}
});

stub(redis, 'info', function (callback) {
callback(new Error('info error'));
});

redis.connect();
});
});

0 comments on commit 3561fab

Please sign in to comment.