New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mongodb

Package Overview
Dependencies
Maintainers
1
Versions
621
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongodb - npm Package Compare versions

Comparing version 1.2.12 to 1.2.13

5

lib/mongodb/commands/db_command.js

@@ -90,6 +90,7 @@ var QueryCommand = require('./query_command').QueryCommand,

DbCommand.createRenameCollectionCommand = function(db, fromCollectionName, toCollectionName) {
DbCommand.createRenameCollectionCommand = function(db, fromCollectionName, toCollectionName, options) {
var renameCollection = db.databaseName + "." + fromCollectionName;
var toCollection = db.databaseName + "." + toCollectionName;
return new DbCommand(db, "admin." + DbCommand.SYSTEM_COMMAND_COLLECTION, QueryCommand.OPTS_NO_CURSOR_TIMEOUT, 0, -1, {'renameCollection':renameCollection, 'to':toCollection}, null);
var dropTarget = options && options.dropTarget ? options.dropTarget : false;
return new DbCommand(db, "admin." + DbCommand.SYSTEM_COMMAND_COLLECTION, QueryCommand.OPTS_NO_CURSOR_TIMEOUT, 0, -1, {'renameCollection':renameCollection, 'to':toCollection, 'dropTarget':dropTarget}, null);
};

@@ -96,0 +97,0 @@

29

lib/mongodb/connection/mongos.js

@@ -45,2 +45,7 @@ var ReadPreference = require('./read_preference').ReadPreference

// Connection timeout
this._connectTimeoutMS = this.socketOptions.connectTimeoutMS
? this.socketOptions.connectTimeoutMS
: 1000;
// Add options to servers

@@ -158,4 +163,13 @@ for(var i = 0; i < this.servers.length; i++) {

var downServer = self.downServers.pop();
// Configuration
var options = {
slaveOk: true,
poolSize: 1,
socketOptions: { connectTimeoutMS: self._connectTimeoutMS },
returnIsMasterResults: true
}
// Attemp to reconnect
downServer.connect(self.db, {returnIsMasterResults: true}, function(_server) {
downServer.connect(self.db, options, function(_server) {
// Return a function to check for the values

@@ -193,3 +207,3 @@ return function(err, result) {

// Execute ping command
self.db.command({ping:1}, {connection:_connection}, function(err, result) {
self.db.command({ping:1}, {failFast:true, connection:_connection}, function(err, result) {
var pingTime = new Date().getTime() - _s;

@@ -218,2 +232,3 @@ // If no server set set the first one, otherwise check

}
// Execute the function

@@ -236,4 +251,12 @@ executePing(self.servers[i]);

server.on("error", errorOrCloseHandler(server));
// Configuration
var options = {
slaveOk: true,
poolSize: 1,
socketOptions: { connectTimeoutMS: self._connectTimeoutMS },
returnIsMasterResults: true
}
// Connect the instance
server.connect(self.db, {returnIsMasterResults: true}, connectHandler(server));
server.connect(self.db, options, connectHandler(server));
}

@@ -240,0 +263,0 @@ }

@@ -35,3 +35,3 @@ var Connection = require('./connection').Connection,

* - **readPreference** {String}, the prefered read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST).
* - **strategy** {String, default:'ping'}, selection strategy for reads choose between (ping and statistical, default is ping)
* - **strategy** {String, default:'ping'}, selection strategy for reads choose between (ping, statistical and none, default is ping)
* - **secondaryAcceptableLatencyMS** {Number, default:15}, sets the range of servers to pick when using NEAREST (lowest ping ms + the latency fence, ex: range of 1 to (1 + 15) ms)

@@ -105,4 +105,2 @@ * - **connectArbiter** {Boolean, default:false}, sets if the driver should connect to arbiters or not.

// Just keeps list of events we allow
this.eventHandlers = {error:[], parseError:[], poolReady:[], message:[], close:[], timeout:[]};
// Internal state of server connection

@@ -112,4 +110,2 @@ this._serverState = 'disconnected';

this._readPreference = null;
// Number of initalized severs
this._numberOfServersLeftToInitialize = 0;
// Do we record server stats or not

@@ -146,3 +142,4 @@ this.recordQueryStats = false;

// Make sure strategy is one of the two allowed
if(this.strategy != null && (this.strategy != 'ping' && this.strategy != 'statistical')) throw new Error("Only ping or statistical strategies allowed");
if(this.strategy != null && (this.strategy != 'ping' && this.strategy != 'statistical' && this.strategy != 'none'))
throw new Error("Only ping or statistical strategies allowed");
if(this.strategy == null) this.strategy = 'ping';

@@ -160,2 +157,5 @@ // Let's set up our strategy object for picking secodaries

// Set logger if strategy exists
if(this.strategyInstance) this.strategyInstance.logger = this.logger;
// Set default connection pool options

@@ -222,3 +222,2 @@ this.socketOptions = this.options.socketOptions != null ? this.options.socketOptions : {};

this.replicasetStatusCheckInterval = this.options['haInterval'] == null ? 5000 : this.options['haInterval'];
this._replicasetTimeoutId = null;

@@ -229,8 +228,6 @@ // Connection timeout

: 1000;
// Current list of servers to test
this.pingCandidateServers = [];
// Last replicaset check time
this.lastReplicaSetTime = new Date().getTime();
// Socket connection timeout
this._socketTimeoutMS = this.socketOptions.socketTimeoutMS
? this.socketOptions.socketTimeoutMS
: (this.replicasetStatusCheckInterval + 1000);
};

@@ -354,3 +351,8 @@

function ping () {
if("disconnected" == self._serverState) return;
// We are disconnected stop pinging and close current connection if any
if("disconnected" == self._serverState) {
if(self._haServer != null) self._haServer.close();
return;
}
// Create a list of all servers we can send the ismaster command to

@@ -384,3 +386,6 @@ var allServers = self._state.master != null ? [self._state.master] : [];

poolSize: 1,
socketOptions: { connectTimeoutMS: self._connectTimeoutMS },
socketOptions: {
connectTimeoutMS: self._connectTimeoutMS,
socketTimeoutMS: self._socketTimeoutMS
},
ssl: self.ssl,

@@ -395,10 +400,27 @@ sslValidate: self.sslValidate,

self._haServer._callBackStore = self._callBackStore;
// Add close handler
// Add error handlers
self.on("close", function() {
if(self._haServer) self._haServer.close();
self._haServer = null;
});
self.on("error", function() {
if(self._haServer) self._haServer.close();
self._haServer = null;
});
self.on("timeout", function() {
if(self._haServer) self._haServer.close();
self._haServer = null;
});
// Connect using the new _server connection to not impact the driver
// behavior on any errors we could possibly run into
self._haServer.connect(db, function(err, result, _server) {
if("disconnected" == self._serverState) {
if(_server.close) _server.close();
return;
}
if(err) {

@@ -423,2 +445,6 @@ if(_server.close) _server.close();

db._executeQueryCommand(cmd, {failFast:true, connection: _server.checkoutReader()}, function(err, res) {
if("disconnected" == self._serverState) {
if(_server.close) _server.close();
return;
}
// If error let's set perform another check

@@ -432,2 +458,3 @@ if(err) return check();

} catch(err) {
if(self._haServer) self._haServer.close();
self._haServer = null;

@@ -1287,3 +1314,5 @@ check();

// If we have a strategy stop it
if(this.strategyInstance) this.strategyInstance.stop();
if(this.strategyInstance) {
this.strategyInstance.stop();
}
// Shut down HA if running connection

@@ -1290,0 +1319,0 @@ if(this._haServer) this._haServer.close();

@@ -1,2 +0,3 @@

var Server = require("../server").Server;
var Server = require("../server").Server
, format = require('util').format;

@@ -15,2 +16,4 @@ // The ping strategy uses pings each server and records the

this.dbs = {};
// Logger api
this.Logger = null;
}

@@ -47,2 +50,3 @@

var candidateServers = [];
var self = this;

@@ -132,2 +136,9 @@ // If we have not provided a list of candidate servers use the default setup

if(self.logger && self.logger.debug) {
self.logger.debug("Ping strategy selection order for tags", tags);
finalCandidates.forEach(function(c) {
self.logger.debug(format("%s:%s = %s ms", c.host, c.port, c.runtimeStats['pingMs']), null);
})
}
// If no candidates available return an error

@@ -138,3 +149,8 @@ if(finalCandidates.length == 0)

// Pick a random acceptable server
return finalCandidates[Math.round(Math.random(1000000) * (finalCandidates.length - 1))].checkoutReader();
var connection = finalCandidates[Math.round(Math.random(1000000) * (finalCandidates.length - 1))].checkoutReader();
if(self.logger && self.logger.debug) {
if(connection)
self.logger.debug("picked server %s:%s", connection.socketOptions.host, connection.socketOptions.port);
}
return connection;
}

@@ -219,7 +235,10 @@

var _ping = function(__db, __serverInstance) {
if(self.state == 'disconnected') return;
if(self.state == 'disconnected') {
self.stop();
return;
}
__db.open(function(err, db) {
if(self.state == 'disconnected') {
return db.close();
if(self.state == 'disconnected' && __db != null) {
return __db.close();
}

@@ -226,0 +245,0 @@

@@ -6,2 +6,4 @@ // The Statistics strategy uses the measure of each end-start time for each

this.replicaset = replicaset;
// Logger api
this.Logger = null;
}

@@ -8,0 +10,0 @@

@@ -604,6 +604,6 @@ var QueryCommand = require('./commands/query_command').QueryCommand,

self.state = Cursor.OPEN;
if(err != null && result == null) return callback(err, null);
if(err != null && result == null) return callback(utils.toError(err), null);
if(!err && result.documents[0] && result.documents[0]['$err']) {
return self.close(function() {callback(result.documents[0]['$err'], null);});
return self.close(function() {callback(utils.toError(result.documents[0]['$err']), null);});
}

@@ -641,3 +641,3 @@

} catch(err) {
return callback(err, null);
return callback(utils.toError(err), null);
}

@@ -707,3 +707,3 @@ }

if(err != null) {
return callback(err, null);
return callback(utils.toError(err), null);
}

@@ -758,3 +758,3 @@

} catch(err) {
callback(err, null);
callback(utils.toError(err), null);
}

@@ -769,3 +769,3 @@ });

var handleClose = function() {
callback(err, null);
callback(utils.toError(err), null);
};

@@ -845,6 +845,6 @@

cursor.nextObject(function(err, item) {
if(err != null) return callback(err, null);
if(err != null) return callback(utils.toError(err), null);
// close the cursor
cursor.close(function(err, result) {
if(err != null) return callback(err, null);
if(err != null) return callback(utils.toError(err), null);
callback(null, item);

@@ -851,0 +851,0 @@ });

{ "name" : "mongodb"
, "description" : "A node.js driver for MongoDB"
, "keywords" : ["mongodb", "mongo", "driver", "db"]
, "version" : "1.2.12"
, "version" : "1.2.13"
, "author" : "Christian Amor Kvalheim <christkv@gmail.com>"

@@ -64,3 +64,3 @@ , "contributors" : [ "Aaron Heckmann",

, "dependencies" : {
"bson": "0.1.7"
"bson": "0.1.8"
}

@@ -67,0 +67,0 @@ , "devDependencies": {

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc