diff --git a/changelog.md b/changelog.md index 5c757c2199..d0cc69f8b6 100644 --- a/changelog.md +++ b/changelog.md @@ -1,6 +1,12 @@ Changelog ========= +## v.2.2.5 - 18 Oct, 2015 + +Bugfixes + +- Fixed undefined options passed to a new instance not accepted (possible with individual .createClient functions) ([@BridgeAR](https://github.com/BridgeAR)) + ## v.2.2.4 - 17 Oct, 2015 Bugfixes diff --git a/index.js b/index.js index f70e85b6d5..ebe44d969a 100644 --- a/index.js +++ b/index.js @@ -36,7 +36,7 @@ parsers.push(require('./lib/parsers/javascript')); function RedisClient(stream, options) { // Copy the options so they are not mutated - options = JSON.parse(JSON.stringify(options)); + options = JSON.parse(JSON.stringify(options || {})); var self = this; if (!stream.cork) { diff --git a/test/connection.spec.js b/test/connection.spec.js index c1a749051e..0ea6e16613 100644 --- a/test/connection.spec.js +++ b/test/connection.spec.js @@ -4,6 +4,7 @@ var assert = require("assert"); var config = require("./lib/config"); var helper = require('./helper'); var redis = config.redis; +var net = require('net'); describe("connection tests", function () { helper.allTests(function(parser, ip, args) { @@ -186,27 +187,16 @@ describe("connection tests", function () { }); }); - it("buffer commands and flush them after ", function (done) { - client = redis.createClient(9999, null, { - parser: parser - }); - - client.on('error', function(e) { - // ignore, b/c expecting a "can't connect" error - }); - - return setTimeout(function() { - client.set('foo', 'bar', function(err, result) { - // This should never be called - return done(err); - }); - - return setTimeout(function() { - assert.strictEqual(client.offline_queue.length, 1); - return done(); - }, 25); - }, 50); - }); + it("works with missing options object for new redis instances", function () { + // This is needed for libraries that have their own createClient function like fakeredis + var cnxOptions = { + port : 6379, + host : '127.0.0.1', + family : ip === 'IPv6' ? 6 : 4 + }; + var net_client = net.createConnection(cnxOptions); + client = new redis.RedisClient(net_client); + }); it("throws on strange connection info", function () { try {