Permalink
Browse files

If there's an error in SELECT and there's no callback, emit the error.

  • Loading branch information...
1 parent 2ff2a74 commit 4672479b917e955ca1a9b17a4172acac9bd9a06b @bengl bengl committed Feb 19, 2014
Showing with 12 additions and 0 deletions.
  1. +2 −0 index.js
  2. +10 −0 test.js
View
@@ -978,6 +978,8 @@ RedisClient.prototype.select = function (db, callback) {
}
if (typeof(callback) === 'function') {
callback(err, res);
+ } else if (err) {
+ self.emit('error', err);
}
});
};
View
10 test.js
@@ -865,6 +865,16 @@ tests.reconnect_select_db_after_pubsub = function() {
});
};
+tests.select_error_emits_if_no_callback = function () {
+ var name = "select_error_emits_if_no_callback";
+
+ client.on('error', with_timeout(name, function (err) {
+ require_error(name)(err);
+ next(name);
+ }, 500));
+ client.select(9999);
+};
+
tests.idle = function () {
var name = "idle";

0 comments on commit 4672479

Please sign in to comment.