Skip to content

Commit

Permalink
refactor(topologies): connect options should extend clonedOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
mbroadst committed Sep 9, 2017
1 parent 226c803 commit 9fb3d86
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
4 changes: 3 additions & 1 deletion lib/mongos.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ var EventEmitter = require('events').EventEmitter,
filterOptions = require('./utils').filterOptions,
mergeOptions = require('./utils').mergeOptions,
getReadPreference = require('./utils').getReadPreference,
os = require('os');
os = require('os'),
assign = require('./utils').assign;

// Get package.json variable
var driverVersion = require('../package.json').version;
Expand Down Expand Up @@ -276,6 +277,7 @@ Mongos.prototype.connect = function(db, _options, callback) {
if ('function' === typeof _options) (callback = _options), (_options = {});
if (_options == null) _options = {};
if (!('function' === typeof callback)) callback = null;
_options = assign({}, this.s.clonedOptions, _options);
self.s.options = _options;

// Update bufferMaxEntries
Expand Down
5 changes: 4 additions & 1 deletion lib/replset.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ var EventEmitter = require('events').EventEmitter,
filterOptions = require('./utils').filterOptions,
getReadPreference = require('./utils').getReadPreference,
mergeOptions = require('./utils').mergeOptions,
os = require('os');
os = require('os'),
assign = require('./utils').assign;

/**
* @fileOverview The **ReplSet** class is a class that represents a Replicaset topology and is
* used to construct connections.
Expand Down Expand Up @@ -312,6 +314,7 @@ ReplSet.prototype.connect = function(db, _options, callback) {
if ('function' === typeof _options) (callback = _options), (_options = {});
if (_options == null) _options = {};
if (!('function' === typeof callback)) callback = null;
_options = assign({}, this.s.clonedOptions, _options);
self.s.options = _options;

// Update bufferMaxEntries
Expand Down
6 changes: 4 additions & 2 deletions lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ var EventEmitter = require('events').EventEmitter,
filterOptions = require('./utils').filterOptions,
mergeOptions = require('./utils').mergeOptions,
getReadPreference = require('./utils').getReadPreference,
os = require('os');
os = require('os'),
assign = require('./utils').assign;

// Get package.json variable
var driverVersion = require('../package.json').version;
Expand Down Expand Up @@ -295,8 +296,9 @@ Object.defineProperty(Server.prototype, 'port', {
Server.prototype.connect = function(_options, callback) {
var self = this;
if ('function' === typeof _options) (callback = _options), (_options = {});
if (_options == null) _options = {};
if (_options == null) _options = this.s.clonedOptions;
if (!('function' === typeof callback)) callback = null;
_options = assign({}, this.s.clonedOptions, _options);
self.s.options = _options;

// Update bufferMaxEntries
Expand Down

0 comments on commit 9fb3d86

Please sign in to comment.