mongodb-core
Advanced tools
Comparing version 2.1.17 to 2.1.18
@@ -0,1 +1,24 @@ | ||
<a name="2.1.18"></a> | ||
## [2.1.18](https://github.com/christkv/mongodb-core/compare/v2.1.17...v2.1.18) (2018-01-02) | ||
### Bug Fixes | ||
* **auth:** don't redeclare BSON variable in plain auth ([4fc77e3](https://github.com/christkv/mongodb-core/commit/4fc77e3)) | ||
* **auth:** remove extra bson include ([4411d2c](https://github.com/christkv/mongodb-core/commit/4411d2c)) | ||
* **connection:** accept incoming missed ssl options from mongo-native-driver ([fd543eb](https://github.com/christkv/mongodb-core/commit/fd543eb)) | ||
* **connection:** added missed tls option ecdhCurve ([ca1d909](https://github.com/christkv/mongodb-core/commit/ca1d909)) | ||
* **connection:** default `family` to undefined rather than 4 ([09916ae](https://github.com/christkv/mongodb-core/commit/09916ae)) | ||
* **connection:** fixing leaky connection ([#234](https://github.com/christkv/mongodb-core/issues/234)) ([7633f10](https://github.com/christkv/mongodb-core/commit/7633f10)) | ||
* **cursor:** check for autoReconnect option only for single server ([c841eb5](https://github.com/christkv/mongodb-core/commit/c841eb5)) | ||
* **secondaries:** fixes connection with secondary readPreference ([5763f5c](https://github.com/christkv/mongodb-core/commit/5763f5c)) | ||
* **timeout:** fixed compatibility with node <=0.12.x ([c7c72b2](https://github.com/christkv/mongodb-core/commit/c7c72b2)), closes [mongodb-js/mongodb-core#247](https://github.com/mongodb-js/mongodb-core/issues/247) [mongodb-js/mongodb-core#247](https://github.com/mongodb-js/mongodb-core/issues/247) [mongodb-js/mongodb-core#248](https://github.com/mongodb-js/mongodb-core/issues/248) [#248](https://github.com/christkv/mongodb-core/issues/248) | ||
### Features | ||
* **replicaset:** More verbose replica set errors emission: ([#231](https://github.com/christkv/mongodb-core/issues/231)) ([de6d220](https://github.com/christkv/mongodb-core/commit/de6d220)) | ||
2.1.17 2017-10-11 | ||
@@ -2,0 +25,0 @@ ----------------- |
"use strict"; | ||
var BSON = require('bson'); | ||
var f = require('util').format | ||
, Binary = BSON.Binary | ||
, retrieveBSON = require('../connection/utils').retrieveBSON | ||
@@ -11,3 +8,4 @@ , Query = require('../connection/commands').Query | ||
var BSON = retrieveBSON(); | ||
var BSON = retrieveBSON() | ||
, Binary = BSON.Binary; | ||
@@ -14,0 +12,0 @@ var AuthSession = function(db, username, password) { |
@@ -26,3 +26,3 @@ "use strict"; | ||
* @param {number} options.port The server port | ||
* @param {number} [options.family=4] Version of IP stack. Defaults to 4. | ||
* @param {number} [options.family=null] IP version for DNS lookup, passed down to Node's [`dns.lookup()` function](https://nodejs.org/api/dns.html#dns_dns_lookup_hostname_options_callback). If set to `6`, will only look for ipv6 addresses. | ||
* @param {boolean} [options.keepAlive=true] TCP Connection keep alive enabled | ||
@@ -78,3 +78,3 @@ * @param {number} [options.keepAliveInitialDelay=300000] Initial delay before TCP keep alive enabled | ||
this.host = options.host || 'localhost'; | ||
this.family = typeof options.family == 'number' ? options.family : 4; | ||
this.family = typeof options.family == 'number' ? options.family : void 0; | ||
this.keepAlive = typeof options.keepAlive == 'boolean' ? options.keepAlive : true; | ||
@@ -110,2 +110,4 @@ this.keepAliveInitialDelay = typeof options.keepAliveInitialDelay == 'number' | ||
this.passphrase = options.passphrase || null; | ||
this.ciphers = options.ciphers || null; | ||
this.ecdhCurve = options.ecdhCurve || null; | ||
this.ssl = typeof options.ssl == 'boolean' ? options.ssl : false; | ||
@@ -382,3 +384,3 @@ this.rejectUnauthorized = typeof options.rejectUnauthorized == 'boolean' ? options.rejectUnauthorized : true; | ||
var legalSslSocketOptions = ['pfx', 'key', 'passphrase', 'cert', 'ca', 'ciphers' | ||
, 'NPNProtocols', 'ALPNProtocols', 'servername' | ||
, 'NPNProtocols', 'ALPNProtocols', 'servername', 'ecdhCurve' | ||
, 'secureProtocol', 'secureContext', 'session' | ||
@@ -413,5 +415,11 @@ , 'minDHSize']; | ||
// Create new connection instance | ||
var connection_options = self.domainSocket | ||
? {path: self.host} | ||
: {port: self.port, host: self.host, family: self.family}; | ||
var connection_options; | ||
if (self.domainSocket) { | ||
connection_options = {path: self.host}; | ||
} else { | ||
connection_options = {port: self.port, host: self.host}; | ||
if (self.family !== void 0) { | ||
connection_options.family = self.family; | ||
} | ||
} | ||
self.connection = net.createConnection(connection_options); | ||
@@ -472,3 +480,3 @@ | ||
} else { | ||
self.connection.on('connect', function() { | ||
self.connection.once('connect', function() { | ||
// Set socket timeout instead of connection timeout | ||
@@ -475,0 +483,0 @@ self.connection.setTimeout(self.socketTimeout); |
@@ -538,3 +538,5 @@ "use strict"; | ||
if(!self.topology.isConnected(self.options)) { | ||
if (!self.topology.s.options.reconnect) { | ||
// Only need this for single server, because repl sets and mongos | ||
// will always continue trying to reconnect | ||
if (self.topology._type === 'server' && !self.topology.s.options.reconnect) { | ||
// Reconnect is disabled, so we'll never reconnect | ||
@@ -541,0 +543,0 @@ return callback(new MongoError('no connection available')); |
@@ -560,7 +560,7 @@ "use strict" | ||
if(err) return self.emit('error', err); | ||
self.emit('error', new MongoError('no primary found in replicaset')); | ||
self.emit('error', new MongoError('no primary found in replicaset or invalid replica set name')); | ||
return self.destroy({force:true}); | ||
} else if(!self.s.replicaSetState.hasSecondary() && self.s.options.secondaryOnlyConnectionAllowed) { | ||
if(err) return self.emit('error', err); | ||
self.emit('error', new MongoError('no secondary found in replicaset')); | ||
self.emit('error', new MongoError('no secondary found in replicaset or invalid replica set name')); | ||
return self.destroy({force:true}); | ||
@@ -673,2 +673,22 @@ } | ||
function shouldTriggerConnect(self) { | ||
var secondaryReadPreferenceString = ReadPreference.secondary.preference || ReadPreference.secondary.mode; | ||
var currentReadPreferenceString = self.s.connectOptions.readPreference && ( | ||
self.s.connectOptions.readPreference.preference || | ||
self.s.connectOptions.readPreference.mode | ||
); | ||
var isConnecting = self.state === CONNECTING; | ||
var hasPrimary = self.s.replicaSetState.hasPrimary(); | ||
var hasSecondary = self.s.replicaSetState.hasSecondary(); | ||
var secondaryOnlyConnectionAllowed = self.s.options.secondaryOnlyConnectionAllowed; | ||
var readPreferenceSecondary = secondaryReadPreferenceString === currentReadPreferenceString; | ||
return ( | ||
(isConnecting && | ||
((readPreferenceSecondary && hasSecondary) || (!readPreferenceSecondary && hasPrimary))) || | ||
(hasSecondary && secondaryOnlyConnectionAllowed) | ||
); | ||
} | ||
function handleInitialConnectEvent(self, event) { | ||
@@ -721,4 +741,3 @@ return function() { | ||
// Do we have a primary or primaryAndSecondary | ||
if(self.state === CONNECTING && self.s.replicaSetState.hasPrimary() | ||
|| (self.s.replicaSetState.hasSecondary() && self.s.options.secondaryOnlyConnectionAllowed)) { | ||
if(shouldTriggerConnect(self)) { | ||
// We are connected | ||
@@ -725,0 +744,0 @@ self.state = CONNECTED; |
@@ -220,3 +220,9 @@ "use strict" | ||
if (!this.isRunning()) { | ||
timer = setTimeout(fn, time); | ||
timer = setTimeout(function() { | ||
fn(); | ||
if (timer && timer._called === undefined) { | ||
// The artificial _called is set here for compatibility with node.js 0.10.x/0.12.x versions | ||
timer._called = true; | ||
} | ||
}, time); | ||
} | ||
@@ -223,0 +229,0 @@ return this; |
{ | ||
"name": "mongodb-core", | ||
"version": "2.1.17", | ||
"version": "2.1.18", | ||
"description": "Core MongoDB driver functionality, no bells and whistles and meant for integration not end applications", | ||
@@ -24,2 +24,3 @@ "main": "index.js", | ||
"devDependencies": { | ||
"request": "2.65.0", | ||
"co": "^4.5.4", | ||
@@ -26,0 +27,0 @@ "coveralls": "^2.11.6", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10582
450422
14
40