You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
Only initiate the parser once per instance and throw sync if the parser can't be found
This commit is contained in:
5
index.js
5
index.js
@@ -90,7 +90,8 @@ function RedisClient(options) {
|
|||||||
this.old_state = null;
|
this.old_state = null;
|
||||||
this.pipeline = 0;
|
this.pipeline = 0;
|
||||||
this.options = options;
|
this.options = options;
|
||||||
|
// Init parser once per instance
|
||||||
|
this.init_parser();
|
||||||
self.stream = net.createConnection(cnx_options);
|
self.stream = net.createConnection(cnx_options);
|
||||||
self.install_stream_listeners();
|
self.install_stream_listeners();
|
||||||
}
|
}
|
||||||
@@ -256,8 +257,6 @@ RedisClient.prototype.on_connect = function () {
|
|||||||
this.stream.setKeepAlive(this.options.socket_keepalive);
|
this.stream.setKeepAlive(this.options.socket_keepalive);
|
||||||
this.stream.setTimeout(0);
|
this.stream.setTimeout(0);
|
||||||
|
|
||||||
this.init_parser();
|
|
||||||
|
|
||||||
if (typeof this.auth_pass === 'string') {
|
if (typeof this.auth_pass === 'string') {
|
||||||
this.do_auth();
|
this.do_auth();
|
||||||
} else {
|
} else {
|
||||||
|
@@ -10,17 +10,15 @@ describe("The node_redis client", function () {
|
|||||||
|
|
||||||
describe("testing parser existence", function () {
|
describe("testing parser existence", function () {
|
||||||
it('throws on non-existence', function (done) {
|
it('throws on non-existence', function (done) {
|
||||||
var mochaListener = helper.removeMochaListener();
|
try {
|
||||||
|
redis.createClient({
|
||||||
process.once('uncaughtException', function (err) {
|
parser: 'nonExistingParser'
|
||||||
process.on('uncaughtException', mochaListener);
|
});
|
||||||
|
done(new Error('test failed'));
|
||||||
|
} catch (err) {
|
||||||
assert.equal(err.message, 'Couldn\'t find named parser nonExistingParser on this system');
|
assert.equal(err.message, 'Couldn\'t find named parser nonExistingParser on this system');
|
||||||
return done();
|
done();
|
||||||
});
|
}
|
||||||
|
|
||||||
redis.createClient({
|
|
||||||
parser: 'nonExistingParser'
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user