Socket
Socket
Sign inDemoInstall

mongodb-core

Package Overview
Dependencies
Maintainers
1
Versions
177
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongodb-core - npm Package Compare versions

Comparing version 1.1.12 to 1.1.13

6

HISTORY.md

@@ -0,1 +1,5 @@

1.1.13 02-24-2015
-----------------
- NODE-365 mongoDB native node.js driver infinite reconnect attempts (fixed issue around handling of retry attempts)
1.1.12 02-16-2015

@@ -86,2 +90,2 @@ -----------------

----------------
- Initial release of mongodb-core
- Initial release of mongodb-core

24

lib/connection/connection.js

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

, MongoError = require('../error')
, Logger = require('./logger');
, Logger = require('./logger');

@@ -46,3 +46,3 @@ var _id = 0;

*/
var Connection = function(options) {
var Connection = function(options) {
// Add event listener

@@ -85,3 +85,3 @@ EventEmitter.call(this);

this.serializationFunction = this.singleBufferSerializtion ? 'toBinUnified' : 'toBin';
// SSL options

@@ -114,3 +114,3 @@ this.ca = options.ca || null;

var errorHandler = function(self) {
return function(err) {
return function(err) {
// Debug information

@@ -142,5 +142,5 @@ if(self.logger.isDebug()) self.logger.debug(f('connection %s for [%s:%s] errored out with [%s]', self.id, self.host, self.port, JSON.stringify(err)));

, MongoError.create(f("connection %s to %s:%s closed", self.id, self.host, self.port))
, self);
, self);
}
}
}
}

@@ -325,3 +325,3 @@

// Create new connection instance
self.connection = self.domainSocket
self.connection = self.domainSocket
? net.createConnection(self.host)

@@ -348,6 +348,6 @@ : net.createConnection(self.port, self.host);

// Attempt SSL connection
self.connection = tls.connect(self.port, self.host, sslOptions, function() {
self.connection = tls.connect(self.port, self.host, sslOptions, function() {
// Error on auth or skip
if(self.connection.authorizationError && self.rejectUnauthorized) {
return self.emit("error", self.connection.authorizationError, self, {ssl:true});
if(self.connection.authorizationError && self.rejectUnauthorized) {
return self.emit("error", self.connection.authorizationError, self, {ssl:true});
}

@@ -365,3 +365,3 @@

// Emit connect event
self.emit('connect', self);
self.emit('connect', self);
});

@@ -391,4 +391,2 @@ }

Connection.prototype.write = function(buffer) {
// console.dir("===========================================================")
// console.dir(buffer)
// Debug log

@@ -395,0 +393,0 @@ if(this.logger.isDebug()) this.logger.debug(f('writing buffer [%s] to %s:%s', buffer.toString('hex'), this.host, this.port));

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

Pool.prototype.connect = function(_options) {
var self = this;
// Set to connecting

@@ -162,14 +163,16 @@ this.state = CONNECTING

for(var i = 0; i < this.size; i++) {
this.options.messageHandler = this.messageHandler;
var connection = new Connection(this.options);
// Add all handlers
connection.once('close', closeHandler(this));
connection.once('error', errorHandler(this));
connection.once('timeout', timeoutHandler(this));
connection.once('parseError', parseErrorHandler(this));
connection.on('connect', connectHandler(this));
setTimeout(function() {
self.options.messageHandler = self.messageHandler;
var connection = new Connection(self.options);
// Add all handlers
connection.once('close', closeHandler(self));
connection.once('error', errorHandler(self));
connection.once('timeout', timeoutHandler(self));
connection.once('parseError', parseErrorHandler(self));
connection.on('connect', connectHandler(self));
// Start connection
connection.connect(_options);
// Start connection
connection.connect(_options);
}, 100);
}

@@ -176,0 +179,0 @@ }

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

* used to construct connections.
*
*
* @example

@@ -38,3 +38,3 @@ * var Server = require('mongodb-core').Server

* , assert = require('assert');
*
*
* var server = new Server({host: 'localhost', port: 27017});

@@ -45,7 +45,7 @@ * // Wait for the connection event

* });
*
*
* // Start connecting
* server.connect();
*/
// All bson types

@@ -127,3 +127,3 @@ var bsonTypes = [b.Long, b.ObjectID, b.Binary, b.Code, b.DBRef, b.Symbol, b.Double, b.Timestamp, b.MaxKey, b.MinKey];

if(result && result.maxWireVersion >= 2) {
return new TwoSixWireProtocolSupport();
return new TwoSixWireProtocolSupport();
}

@@ -138,2 +138,11 @@

var reconnectServer = function(self, state) {
// If the current reconnect retries is 0 stop attempting to reconnect
if(state.currentReconnectRetry == 0) {
return self.destroy(true, true);
}
// Adjust the number of retries
state.currentReconnectRetry = state.currentReconnectRetry - 1;
// Set status to connecting
state.state = CONNECTING;

@@ -232,7 +241,10 @@ // Create a new Pool

// Destroy all connections
self.destroy();
self.destroy();
// Emit error event
if(state.emitError && self.listeners('error').length > 0) self.emit('error', err, self);
// If we specified the driver to reconnect perform it
if(state.reconnect) setTimeout(function() { state.currentReconnectRetry = state.reconnectTries, reconnectServer(self, state) }, state.reconnectInterval);
if(state.reconnect) setTimeout(function() {
// state.currentReconnectRetry = state.reconnectTries,
reconnectServer(self, state)
}, state.reconnectInterval);
}

@@ -248,3 +260,3 @@ }

if(state.readPreferenceStrategies != null) notifyStrategies(self, self.s, 'error', [self]);
if(state.logger.isInfo()) state.logger.info(f('server %s errored out with %s', self.name, JSON.stringify(err)));
if(state.logger.isInfo()) state.logger.info(f('server %s errored out with %s', self.name, JSON.stringify(err)));
// Flush out all the callbacks

@@ -255,7 +267,10 @@ if(state.callbacks) state.callbacks.flush(new MongoError(f("server %s received an error %s", self.name, JSON.stringify(err))));

// If we specified the driver to reconnect perform it
if(state.reconnect) setTimeout(function() { state.currentReconnectRetry = state.reconnectTries, reconnectServer(self, state) }, state.reconnectInterval);
if(state.reconnect) setTimeout(function() {
// state.currentReconnectRetry = state.reconnectTries,
reconnectServer(self, state)
}, state.reconnectInterval);
// Destroy all connections
self.destroy();
}
}
}

@@ -275,3 +290,6 @@ var timeoutHandler = function(self, state) {

// If we specified the driver to reconnect perform it
if(state.reconnect) setTimeout(function() { state.currentReconnectRetry = state.reconnectTries, reconnectServer(self, state) }, state.reconnectInterval);
if(state.reconnect) setTimeout(function() {
// state.currentReconnectRetry = state.reconnectTries,
reconnectServer(self, state)
}, state.reconnectInterval);
// Destroy all connections

@@ -295,3 +313,6 @@ self.destroy();

// If we specified the driver to reconnect perform it
if(state.reconnect) setTimeout(function() { state.currentReconnectRetry = state.reconnectTries, reconnectServer(self, state) }, state.reconnectInterval);
if(state.reconnect) setTimeout(function() {
// state.currentReconnectRetry = state.reconnectTries,
reconnectServer(self, state)
}, state.reconnectInterval);
// Destroy all connections

@@ -303,2 +324,4 @@ self.destroy();

var connectHandler = function(self, state) {
// Reset retries
state.currentReconnectRetry = state.reconnectTries;
// Apply all stored authentications

@@ -368,4 +391,4 @@ var applyAuthentications = function(callback) {

return self.emit('connect', self);
});
});
});
});
});

@@ -412,3 +435,3 @@ }

}
}
}
}

@@ -485,3 +508,3 @@

// Contains the ismaster
, ismaster: null
, ismaster: null
// Contains any alternate strategies for picking

@@ -555,3 +578,3 @@ , readPreferenceStrategies: options.readPreferenceStrategies

this.s.options.bson = new nBSON(bsonTypes);
}
}

@@ -584,3 +607,3 @@ /**

}
// Set the state to connection

@@ -591,3 +614,3 @@ self.s.state = CONNECTING;

self.s.options.messageHandler = messageHandler(self, self.s);
self.s.pool = new Pool(self.s.options);
self.s.pool = new Pool(self.s.options);
}

@@ -603,3 +626,3 @@

// Connect the pool
self.s.pool.connect();
self.s.pool.connect();
}

@@ -611,3 +634,3 @@

*/
Server.prototype.destroy = function(emitClose) {
Server.prototype.destroy = function(emitClose, emitDestroy) {
var self = this;

@@ -617,2 +640,5 @@ if(self.s.logger.isDebug()) self.s.logger.debug(f('destroy called on server %s', self.name));

if(emitClose && self.listeners('close').length > 0) self.emit('close', self);
// Emit destroy event
if(emitDestroy) self.emit('destroy', self);
// Set state as destroyed

@@ -670,3 +696,3 @@ self.s.state = DESTROYED;

if(!self.s.pool.isConnected()) return callback(new MongoError(f("no connection available to server %s", self.name)));
// Execute on all connections

@@ -760,3 +786,3 @@ var onAll = typeof options.onAll == 'boolean' ? options.onAll : false;

if(err) return callback(err);
if(result.documents[0]['$err']
if(result.documents[0]['$err']
|| result.documents[0]['errmsg']

@@ -857,3 +883,3 @@ || result.documents[0]['err']

// If we don't have the mechanism fail
if(self.s.authProviders[mechanism] == null && mechanism != 'default')
if(self.s.authProviders[mechanism] == null && mechanism != 'default')
throw new MongoError(f("auth provider %s does not exist", mechanism));

@@ -868,3 +894,3 @@

}
// Actual arguments

@@ -914,3 +940,3 @@ var finalArguments = [self, self.s.pool, db].concat(args.slice(0)).concat([function(err, r) {

*/
Server.prototype.equals = function(server) {
Server.prototype.equals = function(server) {
if(typeof server == 'string') return server == this.name;

@@ -1009,5 +1035,2 @@ return server.name == this.name;

Server.prototype.cursor = function(ns, cmd, cursorOptions) {
// console.log("============================================ cursor")
// console.dir(cmd)
// console.dir(cursorOptions)
var s = this.s;

@@ -1077,2 +1100,2 @@ cursorOptions = cursorOptions || {};

module.exports = Server;
module.exports = Server;
{
"name": "mongodb-core",
"version": "1.1.12",
"version": "1.1.13",
"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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc