Skip to content

Commit 8da8d78

Browse files
jstewmonAVVS
authored andcommitted
fix(cluster): reorder defaults arguments to prioritize user options (#889)
1 parent e83226b commit 8da8d78

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/cluster/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ class Cluster extends EventEmitter {
6868

6969
this.startupNodes = startupNodes
7070
this.options = defaults(this.options, options, DEFAULT_CLUSTER_OPTIONS)
71+
this.options = defaults({}, options, DEFAULT_CLUSTER_OPTIONS, this.options)
7172

7273
// validate options
7374
if (typeof this.options.scaleReads !== 'function' &&

test/unit/cluster.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,16 @@ describe('cluster', function () {
1515
it('should support frozen options', function () {
1616
var options = Object.freeze({ maxRedirections: 1000 });
1717
var cluster = new Cluster([{ port: 7777 }], options);
18-
expect(cluster.options).to.have.property('showFriendlyErrorStack', false);
18+
expect(cluster.options).to.have.property('maxRedirections', 1000);
1919
expect(cluster.options).to.have.property('showFriendlyErrorStack', false);
2020
expect(cluster.options).to.have.property('scaleReads', 'master');
2121
});
2222

23+
it('should allow overriding Commander options', function () {
24+
const cluster = new Cluster([{ port: 7777 }], {showFriendlyErrorStack: true});
25+
expect(cluster.options).to.have.property('showFriendlyErrorStack', true);
26+
})
27+
2328
it('throws when scaleReads is invalid', function () {
2429
expect(function () {
2530
new Cluster([{}], { scaleReads: 'invalid' });

0 commit comments

Comments
 (0)