From 4672479b917e955ca1a9b17a4172acac9bd9a06b Mon Sep 17 00:00:00 2001 From: Bryan English Date: Tue, 18 Feb 2014 22:02:33 -0800 Subject: [PATCH] If there's an error in SELECT and there's no callback, emit the error. --- index.js | 2 ++ test.js | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/index.js b/index.js index 6e87bb1..0291f17 100644 --- a/index.js +++ b/index.js @@ -978,6 +978,8 @@ RedisClient.prototype.select = function (db, callback) { } if (typeof(callback) === 'function') { callback(err, res); + } else if (err) { + self.emit('error', err); } }); }; diff --git a/test.js b/test.js index b685044..e0bcff4 100644 --- a/test.js +++ b/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";