You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-04 15:02:09 +03:00
Fix domain handling and tls camelCase settings
Fixes #1106 Fixes #1103 Closes #1104
This commit is contained in:
@@ -1,6 +1,13 @@
|
|||||||
Changelog
|
Changelog
|
||||||
=========
|
=========
|
||||||
|
|
||||||
|
## v.2.6.3 - 31 Oct, 2016
|
||||||
|
|
||||||
|
Bugfixes
|
||||||
|
|
||||||
|
- Do not change the tls setting to camel_case
|
||||||
|
- Fix domain handling in combination with the offline queue (2.5.3 regression)
|
||||||
|
|
||||||
## v.2.6.2 - 16 Jun, 2016
|
## v.2.6.2 - 16 Jun, 2016
|
||||||
|
|
||||||
Bugfixes
|
Bugfixes
|
||||||
|
8
index.js
8
index.js
@@ -868,16 +868,16 @@ RedisClient.prototype.internal_send_command = function (command_obj) {
|
|||||||
var big_data = false;
|
var big_data = false;
|
||||||
var args_copy = new Array(len);
|
var args_copy = new Array(len);
|
||||||
|
|
||||||
|
if (process.domain && command_obj.callback) {
|
||||||
|
command_obj.callback = process.domain.bind(command_obj.callback);
|
||||||
|
}
|
||||||
|
|
||||||
if (this.ready === false || this.stream.writable === false) {
|
if (this.ready === false || this.stream.writable === false) {
|
||||||
// Handle offline commands right away
|
// Handle offline commands right away
|
||||||
handle_offline_command(this, command_obj);
|
handle_offline_command(this, command_obj);
|
||||||
return false; // Indicate buffering
|
return false; // Indicate buffering
|
||||||
}
|
}
|
||||||
|
|
||||||
if (process.domain && command_obj.callback) {
|
|
||||||
command_obj.callback = process.domain.bind(command_obj.callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < len; i += 1) {
|
for (i = 0; i < len; i += 1) {
|
||||||
if (typeof args[i] === 'string') {
|
if (typeof args[i] === 'string') {
|
||||||
// 30000 seemed to be a good value to switch to buffers after testing and checking the pros and cons
|
// 30000 seemed to be a good value to switch to buffers after testing and checking the pros and cons
|
||||||
|
@@ -57,6 +57,10 @@ function clone (obj) {
|
|||||||
var elems = Object.keys(obj);
|
var elems = Object.keys(obj);
|
||||||
var elem;
|
var elem;
|
||||||
while (elem = elems.pop()) {
|
while (elem = elems.pop()) {
|
||||||
|
if (elem === 'tls') { // special handle tls
|
||||||
|
copy[elem] = obj[elem];
|
||||||
|
continue;
|
||||||
|
}
|
||||||
// Accept camelCase options and convert them to snake_case
|
// Accept camelCase options and convert them to snake_case
|
||||||
var snake_case = elem.replace(/[A-Z][^A-Z]/g, '_$&').toLowerCase();
|
var snake_case = elem.replace(/[A-Z][^A-Z]/g, '_$&').toLowerCase();
|
||||||
// If camelCase is detected, pass it to the client, so all variables are going to be camelCased
|
// If camelCase is detected, pass it to the client, so all variables are going to be camelCased
|
||||||
|
@@ -623,6 +623,19 @@ describe('The node_redis client', function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('keeps the same domain by using the offline queue', function (done) {
|
||||||
|
client.end(true);
|
||||||
|
client = redis.createClient();
|
||||||
|
var testDomain = require('domain').create();
|
||||||
|
testDomain.run(function () {
|
||||||
|
client.set('FOOBAR', 'def', function () {
|
||||||
|
assert.strictEqual(process.domain, testDomain);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
require('domain').create();
|
||||||
|
});
|
||||||
|
|
||||||
it('catches all errors from within the domain', function (done) {
|
it('catches all errors from within the domain', function (done) {
|
||||||
var domain = require('domain').create();
|
var domain = require('domain').create();
|
||||||
|
|
||||||
|
@@ -35,12 +35,16 @@ describe('utils.js', function () {
|
|||||||
retryStrategy: false,
|
retryStrategy: false,
|
||||||
nested: {
|
nested: {
|
||||||
onlyContainCamelCaseOnce: true
|
onlyContainCamelCaseOnce: true
|
||||||
|
},
|
||||||
|
tls: {
|
||||||
|
rejectUnauthorized: true
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
assert.strictEqual(Object.keys(a).length, 4);
|
assert.strictEqual(Object.keys(a).length, 5);
|
||||||
assert.strictEqual(a.option_one_two, true);
|
assert.strictEqual(a.option_one_two, true);
|
||||||
assert.strictEqual(a.retry_strategy, false);
|
assert.strictEqual(a.retry_strategy, false);
|
||||||
assert.strictEqual(a.camel_case, true);
|
assert.strictEqual(a.camel_case, true);
|
||||||
|
assert.strictEqual(a.tls.rejectUnauthorized, true);
|
||||||
assert.strictEqual(Object.keys(a.nested).length, 1);
|
assert.strictEqual(Object.keys(a.nested).length, 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user