diff --git a/index.js b/index.js index 6cea8bd4c6..439c784c8d 100644 --- a/index.js +++ b/index.js @@ -556,12 +556,8 @@ RedisClient.prototype.connection_gone = function (why, error) { if (this.retry_delay instanceof Error) { error = this.retry_delay; } - var errorMessage = 'Redis connection in broken state: '; - if (this.retry_totaltime >= this.connect_timeout) { - errorMessage += 'connection timeout exceeded.'; - } else { - errorMessage += 'maximum connection attempts exceeded.'; - } + + var errorMessage = 'Redis connection in broken state: retry aborted.'; this.flush_and_error({ message: errorMessage, @@ -581,13 +577,7 @@ RedisClient.prototype.connection_gone = function (why, error) { } if (this.retry_totaltime >= this.connect_timeout) { - var message = 'Redis connection in broken state: '; - if (this.retry_totaltime >= this.connect_timeout) { - message += 'connection timeout exceeded.'; - } else { - message += 'maximum connection attempts exceeded.'; - } - + var message = 'Redis connection in broken state: connection timeout exceeded.'; this.flush_and_error({ message: message, code: 'CONNECTION_BROKEN', @@ -864,11 +854,9 @@ RedisClient.prototype.internal_send_command = function (command_obj) { if (command_obj.args && command_obj.args.length) { undefinedArgError.args = command_obj.args; } - if (command_obj.callback) { - command_obj.callback(undefinedArgError); - return false; - } - throw undefinedArgError; + // there is always a callback in this scenario + command_obj.callback(undefinedArgError); + return false; } else { // Seems like numbers are converted fast using string concatenation args_copy[i] = '' + args[i]; diff --git a/test/commands/set.spec.js b/test/commands/set.spec.js index d2d36491a9..33a8bfa22c 100644 --- a/test/commands/set.spec.js +++ b/test/commands/set.spec.js @@ -150,6 +150,10 @@ describe("The 'set' method", function () { client.get('foo', helper.isNull(done)); }); + it('calls callback with error if null value is passed', function (done) { + client.set('foo', null, helper.isError(done)); + }); + it('emit an error with only the key set', function (done) { client.on('error', function (err) { assert.equal(err.message, "ERR wrong number of arguments for 'set' command"); diff --git a/test/connection.spec.js b/test/connection.spec.js index 0913a26ff6..7c153b3926 100644 --- a/test/connection.spec.js +++ b/test/connection.spec.js @@ -239,7 +239,7 @@ describe('connection tests', function () { retryStrategy: function (options) { if (options.totalRetryTime > 150) { client.set('foo', 'bar', function (err, res) { - assert.strictEqual(err.message, 'Redis connection in broken state: maximum connection attempts exceeded.'); + assert.strictEqual(err.message, 'Redis connection in broken state: retry aborted.'); assert.strictEqual(err.origin.message, 'Connection timeout'); done(); }); @@ -257,7 +257,7 @@ describe('connection tests', function () { retry_strategy: function (options) { if (options.total_retry_time > 150) { client.set('foo', 'bar', function (err, res) { - assert.strictEqual(err.message, 'Redis connection in broken state: maximum connection attempts exceeded.'); + assert.strictEqual(err.message, 'Redis connection in broken state: retry aborted.'); assert.strictEqual(err.code, 'CONNECTION_BROKEN'); assert.strictEqual(err.origin.code, 'ECONNREFUSED'); done(); @@ -287,7 +287,7 @@ describe('connection tests', function () { }, 50); client.on('error', function (err) { if (err instanceof redis.AbortError) { - assert.strictEqual(err.message, 'Redis connection in broken state: maximum connection attempts exceeded.'); + assert.strictEqual(err.message, 'Redis connection in broken state: retry aborted.'); assert.strictEqual(err.code, 'CONNECTION_BROKEN'); unhookIntercept(); redis.debugMode = false; diff --git a/test/multi.spec.js b/test/multi.spec.js index 498168f9d5..2465dfc2d0 100644 --- a/test/multi.spec.js +++ b/test/multi.spec.js @@ -234,7 +234,7 @@ describe("The 'multi' method", function () { }); client.multi([['set', 'foo', 'bar'], ['get', 'foo']]).exec(function (err, res) { - assert(/Redis connection in broken state: maximum connection attempts exceeded/.test(err.message)); + assert(/Redis connection in broken state: retry aborted/.test(err.message)); assert.strictEqual(err.errors.length, 2); assert.strictEqual(err.errors[0].args.length, 2); });