Skip to content

Commit

Permalink
Emits "error" when all sentinels are unreachable. Close #200
Browse files Browse the repository at this point in the history
  • Loading branch information
luin committed Nov 25, 2015
1 parent 65dc474 commit 34ed2c5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ This file is a manually maintained list of changes for each release. Feel free t

## Master Branch (Unreleased)

* [Sentinel] Emits "error" when all sentinels are unreachable ([#200](https://github.com/luin/ioredis/issues/200)).

## v1.11.0 - November 19, 2015

* Emits "select" event when the database changed.
Expand Down
1 change: 1 addition & 0 deletions lib/redis.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ Redis.prototype.connect = function (callback) {
this.connector.connect(function (err, stream) {
if (err) {
_this.flushQueue(err);
_this.silentEmit('error', err);
reject(err);
return;
}
Expand Down
16 changes: 14 additions & 2 deletions test/functional/sentinel.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,22 @@ describe('sentinel', function () {
});

redis.get('foo', function (error) {
finish();
expect(error.message).to.match(/are unreachable/);
redis.disconnect();
done();
});

redis.on('error', function (error) {
expect(error.message).to.match(/are unreachable/);
finish();
});

var pending = 2;
function finish() {
if (!--pending) {
redis.disconnect();
done();
}
}
});

it('should close the connection to the sentinel when resolving successfully', function (done) {
Expand Down

0 comments on commit 34ed2c5

Please sign in to comment.