Skip to content

Commit 39c8820

Browse files
authored
Merge pull request #1166 from NodeRedis/fix-bugs
Fix domain and camelCase bug
2 parents d8d0e2d + 4e98cb9 commit 39c8820

File tree

6 files changed

+34
-6
lines changed

6 files changed

+34
-6
lines changed

changelog.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
Changelog
22
=========
33

4+
## v.2.6.3 - 31 Oct, 2016
5+
6+
Bugfixes
7+
8+
- Do not change the tls setting to camel_case
9+
- Fix domain handling in combination with the offline queue (2.5.3 regression)
10+
411
## v.2.6.2 - 16 Jun, 2016
512

613
Bugfixes

index.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -868,16 +868,16 @@ RedisClient.prototype.internal_send_command = function (command_obj) {
868868
var big_data = false;
869869
var args_copy = new Array(len);
870870

871+
if (process.domain && command_obj.callback) {
872+
command_obj.callback = process.domain.bind(command_obj.callback);
873+
}
874+
871875
if (this.ready === false || this.stream.writable === false) {
872876
// Handle offline commands right away
873877
handle_offline_command(this, command_obj);
874878
return false; // Indicate buffering
875879
}
876880

877-
if (process.domain && command_obj.callback) {
878-
command_obj.callback = process.domain.bind(command_obj.callback);
879-
}
880-
881881
for (i = 0; i < len; i += 1) {
882882
if (typeof args[i] === 'string') {
883883
// 30000 seemed to be a good value to switch to buffers after testing and checking the pros and cons

lib/utils.js

+4
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ function clone (obj) {
5757
var elems = Object.keys(obj);
5858
var elem;
5959
while (elem = elems.pop()) {
60+
if (elem === 'tls') { // special handle tls
61+
copy[elem] = obj[elem];
62+
continue;
63+
}
6064
// Accept camelCase options and convert them to snake_case
6165
var snake_case = elem.replace(/[A-Z][^A-Z]/g, '_$&').toLowerCase();
6266
// If camelCase is detected, pass it to the client, so all variables are going to be camelCased

test/connection.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ describe('connection tests', function () {
371371
if (err.code === 'ENETUNREACH') { // The test is run without a internet connection. Pretent it works
372372
return done();
373373
}
374-
assert(/Redis connection in broken state: connection timeout.*?exceeded./.test(err.message));
374+
assert(/Redis connection in broken state: connection timeout.*?exceeded./.test(err.message), err.message);
375375
// The code execution on windows is very slow at times
376376
var add = process.platform !== 'win32' ? 15 : 200;
377377
var now = Date.now();

test/node_redis.spec.js

+13
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,19 @@ describe('The node_redis client', function () {
623623
});
624624
});
625625

626+
it('keeps the same domain by using the offline queue', function (done) {
627+
client.end(true);
628+
client = redis.createClient();
629+
var testDomain = require('domain').create();
630+
testDomain.run(function () {
631+
client.set('FOOBAR', 'def', function () {
632+
assert.strictEqual(process.domain, testDomain);
633+
done();
634+
});
635+
});
636+
require('domain').create();
637+
});
638+
626639
it('catches all errors from within the domain', function (done) {
627640
var domain = require('domain').create();
628641

test/utils.spec.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,16 @@ describe('utils.js', function () {
3535
retryStrategy: false,
3636
nested: {
3737
onlyContainCamelCaseOnce: true
38+
},
39+
tls: {
40+
rejectUnauthorized: true
3841
}
3942
});
40-
assert.strictEqual(Object.keys(a).length, 4);
43+
assert.strictEqual(Object.keys(a).length, 5);
4144
assert.strictEqual(a.option_one_two, true);
4245
assert.strictEqual(a.retry_strategy, false);
4346
assert.strictEqual(a.camel_case, true);
47+
assert.strictEqual(a.tls.rejectUnauthorized, true);
4448
assert.strictEqual(Object.keys(a.nested).length, 1);
4549
});
4650

0 commit comments

Comments
 (0)