diff --git a/index.js b/index.js index 175477b..fbc6f55 100644 --- a/index.js +++ b/index.js @@ -90,7 +90,8 @@ function RedisClient(options) { this.old_state = null; this.pipeline = 0; this.options = options; - + // Init parser once per instance + this.init_parser(); self.stream = net.createConnection(cnx_options); self.install_stream_listeners(); } @@ -256,8 +257,6 @@ RedisClient.prototype.on_connect = function () { this.stream.setKeepAlive(this.options.socket_keepalive); this.stream.setTimeout(0); - this.init_parser(); - if (typeof this.auth_pass === 'string') { this.do_auth(); } else { diff --git a/test/node_redis.spec.js b/test/node_redis.spec.js index 2c03de5..ca13878 100644 --- a/test/node_redis.spec.js +++ b/test/node_redis.spec.js @@ -10,17 +10,15 @@ describe("The node_redis client", function () { describe("testing parser existence", function () { it('throws on non-existence', function (done) { - var mochaListener = helper.removeMochaListener(); - - process.once('uncaughtException', function (err) { - process.on('uncaughtException', mochaListener); + try { + redis.createClient({ + parser: 'nonExistingParser' + }); + done(new Error('test failed')); + } catch (err) { assert.equal(err.message, 'Couldn\'t find named parser nonExistingParser on this system'); - return done(); - }); - - redis.createClient({ - parser: 'nonExistingParser' - }); + done(); + } }); });