Socket
Socket
Sign inDemoInstall

mongodb-core

Package Overview
Dependencies
2
Maintainers
1
Versions
177
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.1.8 to 2.1.9

8

HISTORY.md

@@ -0,1 +1,9 @@

2.1.9 2017-03-17
----------------
* Return lastIsMaster correctly when connecting with secondaryOnlyConnectionAllowed is set to true and only a secondary is available in replica state.
* Clone options when passed to wireProtocol handler to avoid intermittent modifications causing errors.
* Ensure SSL error propegates better for Replset connections when there is a SSL validation error.
* NODE-957 Fixed issue where < batchSize not causing cursor to be closed on execution of first batch.
* NODE-958 Store reconnectConnection on pool object to allow destroy to close immediately.
2.1.8 2017-02-13

@@ -2,0 +10,0 @@ ----------------

5

lib/connection/connection.js

@@ -16,3 +16,3 @@ "use strict";

var debugFields = ['host', 'port', 'size', 'keepAlive', 'keepAliveInitialDelay', 'noDelay'
, 'connectionTimeout', 'socketTimeout', 'singleBufferSerializtion', 'ssl', 'ca', 'cert'
, 'connectionTimeout', 'socketTimeout', 'singleBufferSerializtion', 'ssl', 'ca', 'crl', 'cert'
, 'rejectUnauthorized', 'promoteLongs', 'promoteValues', 'promoteBuffers', 'checkServerIdentity'];

@@ -36,2 +36,3 @@ var connectionAccounting = false;

* @param {Buffer} [options.ca] SSL Certificate store binary buffer
* @param {Buffer} [options.crl] SSL Certificate revocation store binary buffer
* @param {Buffer} [options.cert] SSL Certificate binary buffer

@@ -95,2 +96,3 @@ * @param {Buffer} [options.key] SSL Key file binary buffer

this.ca = options.ca || null;
this.crl = options.crl || null;
this.cert = options.cert || null;

@@ -422,2 +424,3 @@ this.key = options.key || null;

if(self.ca) sslOptions.ca = self.ca;
if(self.crl) sslOptions.crl = self.crl;
if(self.cert) sslOptions.cert = self.cert;

@@ -424,0 +427,0 @@ if(self.key) sslOptions.key = self.key;

37

lib/connection/pool.js

@@ -46,2 +46,3 @@ "use strict";

* @param {Buffer} [options.ca] SSL Certificate store binary buffer
* @param {Buffer} [options.crl] SSL Certificate revocation store binary buffer
* @param {Buffer} [options.cert] SSL Certificate binary buffer

@@ -80,3 +81,3 @@ * @param {Buffer} [options.key] SSL Key file binary buffer

ssl: false, checkServerIdentity: true,
ca: null, cert: null, key: null, passPhrase: null,
ca: null, crl: null, cert: null, key: null, passPhrase: null,
rejectUnauthorized: false,

@@ -126,2 +127,5 @@ promoteLongs: true,

// Contains the reconnect connection
this.reconnectConnection = null;
// Are we currently authenticating

@@ -347,2 +351,4 @@ this.authenticating = false;

self.availableConnections.push(connection);
// Set the reconnectConnection to null
self.reconnectConnection = null;
// Emit reconnect event

@@ -357,12 +363,12 @@ self.emit('reconnect', self);

// Create a connection
var connection = new Connection(messageHandler(self), self.options);
self.reconnectConnection = new Connection(messageHandler(self), self.options);
// Add handlers
connection.on('close', _connectionFailureHandler(self, 'close'));
connection.on('error', _connectionFailureHandler(self, 'error'));
connection.on('timeout', _connectionFailureHandler(self, 'timeout'));
connection.on('parseError', _connectionFailureHandler(self, 'parseError'));
self.reconnectConnection.on('close', _connectionFailureHandler(self, 'close'));
self.reconnectConnection.on('error', _connectionFailureHandler(self, 'error'));
self.reconnectConnection.on('timeout', _connectionFailureHandler(self, 'timeout'));
self.reconnectConnection.on('parseError', _connectionFailureHandler(self, 'parseError'));
// On connection
connection.on('connect', _connectHandler(self));
self.reconnectConnection.on('connect', _connectHandler(self));
// Attempt connection
connection.connect();
self.reconnectConnection.connect();
}

@@ -515,3 +521,3 @@ }

* @method
* @return {Connectio[]} The pool connections
* @return {Connection[]} The pool connections
*/

@@ -842,2 +848,13 @@ Pool.prototype.allConnections = function() {

// Clear out the reconnect if set
if (this.reconnectId) {
clearTimeout(this.reconnectId);
}
// If we have a reconnect connection running, close
// immediately
if (this.reconnectConnection) {
this.reconnectConnection.destroy();
}
// Wait for the operations to drain before we close the pool

@@ -1061,3 +1078,3 @@ function checkStatus() {

// If we are authenticating at the moment
// If we are c at the moment
// Do not automatially put in available connections

@@ -1064,0 +1081,0 @@ // As we need to apply the credentials first

@@ -13,2 +13,3 @@ "use strict"

clone = require('./shared').clone,
cloneOptions = require('./shared').cloneOptions,
createClientInfo = require('./shared').createClientInfo;

@@ -93,2 +94,3 @@

* @param {Buffer} [options.ca] SSL Certificate store binary buffer
* @param {Buffer} [options.crl] SSL Certificate revocation store binary buffer
* @param {Buffer} [options.cert] SSL Certificate binary buffer

@@ -884,4 +886,8 @@ * @param {Buffer} [options.key] SSL Key file binary buffer

// Cloned options
var clonedOptions = cloneOptions(options);
clonedOptions.topology = self;
// Execute the command
server.command(ns, cmd, options, callback);
server.command(ns, cmd, clonedOptions, callback);
}

@@ -888,0 +894,0 @@

@@ -77,2 +77,3 @@ "use strict"

* @param {Buffer} [options.ca] SSL Certificate store binary buffer
* @param {Buffer} [options.crl] SSL Certificate revocation store binary buffer
* @param {Buffer} [options.cert] SSL Certificate binary buffer

@@ -245,6 +246,7 @@ * @param {Buffer} [options.key] SSL Key file binary buffer

var count = servers.length;
var error = null;
// Handle events
var _handleEvent = function(self, event) {
return function() {
return function(err) {
var _self = this;

@@ -299,2 +301,4 @@ count = count - 1;

this.destroy();
} else if(event == 'error') {
error = err;
}

@@ -306,3 +310,3 @@

// Are we done finish up callback
if(count == 0) { callback(); }
if(count == 0) { callback(error); }
}

@@ -526,7 +530,9 @@ }

if(_process === setTimeout) {
return connectNewServers(self, self.s.replicaSetState.unknownServers, function() {
return connectNewServers(self, self.s.replicaSetState.unknownServers, function(err) {
if(!self.s.replicaSetState.hasPrimary() && !self.s.options.secondaryOnlyConnectionAllowed) {
if(err) return self.emit('error', err);
self.emit('error', new MongoError('no primary found in replicaset'));
return self.destroy();
} 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'));

@@ -881,2 +887,10 @@ return self.destroy();

ReplSet.prototype.lastIsMaster = function() {
// If secondaryOnlyConnectionAllowed and no primary but secondary
// return the secondaries ismaster result.
if (this.s.options.secondaryOnlyConnectionAllowed
&& !this.s.replicaSetState.hasPrimary()
&& this.s.replicaSetState.hasSecondary()) {
return this.s.replicaSetState.secondaries[0].lastIsMaster();
}
return this.s.replicaSetState.primary

@@ -883,0 +897,0 @@ ? this.s.replicaSetState.primary.lastIsMaster() : this.ismaster;

@@ -25,3 +25,3 @@ "use strict"

, 'port', 'size', 'keepAlive', 'keepAliveInitialDelay', 'noDelay', 'connectionTimeout', 'checkServerIdentity'
, 'socketTimeout', 'singleBufferSerializtion', 'ssl', 'ca', 'cert', 'key', 'rejectUnauthorized', 'promoteLongs', 'promoteValues'
, 'socketTimeout', 'singleBufferSerializtion', 'ssl', 'ca', 'crl', 'cert', 'key', 'rejectUnauthorized', 'promoteLongs', 'promoteValues'
, 'promoteBuffers', 'servername'];

@@ -55,2 +55,3 @@

* @param {Buffer} [options.ca] SSL Certificate store binary buffer
* @param {Buffer} [options.crl] SSL Certificate revocation store binary buffer
* @param {Buffer} [options.cert] SSL Certificate binary buffer

@@ -328,3 +329,3 @@ * @param {Buffer} [options.key] SSL Key file binary buffer

self.initalConnect = false;
return self.emit('error', new MongoError(f('failed to connect to server [%s] on first connect', self.name)));
return self.emit('error', new MongoError(f('failed to connect to server [%s] on first connect [%s]', self.name, err)));
}

@@ -500,4 +501,6 @@

// Create a query instance
var query = new Query(self.s.bson, ns, cmd, queryOptions);
// Are we executing against a specific topology
var topology = options.topology || {};
// Create the query object
var query = self.wireProtocolHandler.command(self.s.bson, ns, cmd, {}, topology, options);
// Set slave OK of the query

@@ -504,0 +507,0 @@ query.slaveOk = options.readPreference ? options.readPreference.slaveOk() : false;

@@ -391,4 +391,2 @@ "use strict";

if(cmd.limit) findCmd.limit = cmd.limit;
// Add a batchSize
if(typeof cmd.batchSize == 'number') findCmd.batchSize = Math.abs(cmd.batchSize);

@@ -401,2 +399,15 @@ // Check if we wish to have a singleBatch

// Add a batchSize
if(typeof cmd.batchSize == 'number') {
if (cmd.batchSize < 0) {
if (cmd.limit != 0 && Math.abs(cmd.batchSize) < Math.abs(cmd.limit)) {
findCmd.limit = Math.abs(cmd.batchSize);
}
findCmd.singleBatch = true;
}
findCmd.batchSize = Math.abs(cmd.batchSize);
}
// If we have comment set

@@ -403,0 +414,0 @@ if(cmd.comment) findCmd.comment = cmd.comment;

{
"name": "mongodb-core",
"version": "2.1.8",
"version": "2.1.9",
"description": "Core MongoDB driver functionality, no bells and whistles and meant for integration not end applications",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc