Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mongodb

Package Overview
Dependencies
Maintainers
1
Versions
575
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 0.9.7-1 to 0.9.7-1.1

6

lib/mongodb/connection/server.js

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

// Create a default connect handler, overriden when using replicasets
var connectCallback = function(err, reply) {
var connectCallback = function(err, reply) {
if(err != null) return callback(err, null);

@@ -212,3 +212,3 @@ server.master = reply.documents[0].ismaster == 1 ? true : false;

// Handle errors
connectionPool.on("error", function(message) {
connectionPool.on("error", function(message) {
// Force close the pool

@@ -264,3 +264,3 @@ if(connectionPool.isConnected()) connectionPool.stop();

// Force close the pool
if(connectionPool.isConnected()) self.stop();
if(connectionPool.isConnected()) server.close();
// Emit error

@@ -267,0 +267,0 @@ server.emit("error", message);

@@ -817,15 +817,9 @@ var QueryCommand = require('./commands/query_command').QueryCommand,

var numberOfRetriesDone = numberOfTimes;
// // Ensure we listen to errors on the serverConfig (don't want unexpected exceptions escaping during listening)
// self.serverConfig.on("error", function(err) {
// console.log("============================== received error")
// console.dir(err)
// })
// Retry function, execute once
var retryFunction = function(_self, _numberOfRetriesDone, _retryInMilliseconds, _numberOfTimes, _command, _db_command, _options, _callback) {
_self.serverConfig.connect(_self, {firstCall: false}, function(err, result) {
_self.serverConfig.connect(_self, {firstCall: true}, function(err, result) {
// Adjust the number of retries left
_numberOfRetriesDone = _numberOfRetriesDone - 1;
// Definitively restart
if(err != null && _numberOfRetriesDone > 0) {
// Adjust the number of retries left
_numberOfRetriesDone = _numberOfRetriesDone - 1;
// Force close the current connections

@@ -838,5 +832,7 @@ _self.serverConfig.close(function(err) {

});
} else if(err != null && numberOfRetriesDone <= 0) {
} else if(err != null && _numberOfRetriesDone <= 0) {
// Set connected
_self.state = 'disconnected';
// Force close the current connections
_self.serverConfig.close(function(err) {
_self.serverConfig.close(function(_err) {
// Force close the current connections

@@ -901,4 +897,2 @@ _callback(err, null);

} else {
// Adjust the number of retries left
_numberOfRetriesDone = _numberOfRetriesDone - 1;
// Force close the current connections

@@ -998,3 +992,2 @@ _self.serverConfig.close(function(err) {

options = args.length ? args.shift() : {};
// If the pool is not connected, attemp to reconnect to send the message

@@ -1001,0 +994,0 @@ if(!this.serverConfig.isConnected() && this.serverConfig.autoReconnect && this.state != 'connecting') {

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

@@ -6,0 +6,0 @@ , "contributors" : [ "Aaron Heckmann",

@@ -64,3 +64,3 @@ var mongodb = process.env['TEST_NATIVE'] != null ? require('../../lib/mongodb').native() : require('../../lib/mongodb').pure();

}, 500);
// Wait for a second and then kill the server

@@ -95,162 +95,54 @@ setTimeout(function() {

});
},
// Step(
// function bootTheServerWithNoAuth() {
// serverManager = new ServerManager({auth:false, purgedirectories:true})
// serverManager.start(true, this);
// },
//
// function openDbs() {
// db1.open(this.parallel());
// db2.open(this.parallel());
// admin.open(this.parallel());
// },
//
// function addAdminUserToDatabase(err, db1, db2, admin) {
// test.equal(null, err);
// admin.addUser('admin', 'admin', this);
// },
//
// function restartServerInAuthMode(err, result) {
// test.equal(null, err);
// test.equal('7c67ef13bbd4cae106d959320af3f704', result.shift().pwd);
//
// db1.close();
// db2.close();
// admin.close();
//
// serverManager = new ServerManager({auth:true, purgedirectories:false})
// serverManager.start(true, this);
// },
//
// function openDbs() {
// db1.open(this.parallel());
// db2.open(this.parallel());
// admin.open(this.parallel());
// },
//
// function authenticateAdminUser(err) {
// test.equal(null, err);
//
// admin.authenticate('admin', 'admin', this.parallel());
// db1.admin().authenticate('admin', 'admin', this.parallel());
// db2.admin().authenticate('admin', 'admin', this.parallel());
// },
//
// function addDbUsersForAuthentication(err, result1, result2, result3) {
// test.equal(null, err);
// test.ok(result1);
// test.ok(result2);
// test.ok(result3);
//
// db1.addUser('user1', 'secret', this.parallel());
// db2.addUser('user2', 'secret', this.parallel());
// },
//
// function closeAdminConnection(err, result1, result2) {
// test.ok(err == null);
// test.ok(result1 != null);
// test.ok(result2 != null);
// admin.logout(this.parallel());
// db1.admin().logout(this.parallel());
// db2.admin().logout(this.parallel());
// },
//
// function failAuthenticationWithDbs(err, result) {
// var self = this;
//
// db1.collection('stuff', function(err, collection) {
// collection.insert({a:2}, {safe:true}, self.parallel());
// });
//
// db2.collection('stuff', function(err, collection) {
// collection.insert({a:2}, {safe:true}, self.parallel());
// });
// },
//
// function authenticateAgainstDbs(err, result) {
// test.ok(err != null);
//
// db1.authenticate('user1', 'secret', this.parallel());
// db2.authenticate('user2', 'secret', this.parallel());
// },
//
// function correctlyInsertRowToDbs(err, result1, result2) {
// var self = this;
// test.ok(err == null);
// test.ok(result1);
// test.ok(result2);
//
// db1.collection('stuff', function(err, collection) {
// collection.insert({a:2}, {safe:true}, self.parallel());
// });
//
// db2.collection('stuff', function(err, collection) {
// collection.insert({a:2}, {safe:true}, self.parallel());
// });
// },
//
// function validateCorrectInsertsAndBounceServer(err, result1, result2) {
// test.ok(err == null);
// test.ok(result1 != null);
// test.ok(result2 != null);
//
// serverManager = new ServerManager({auth:true, purgedirectories:false})
// serverManager.start(true, this);
// },
//
// function reconnectAndVerifyThatAuthIsAutomaticallyApplied() {
// var self = this;
// db1.collection('stuff', function(err, collection) {
//
// collection.find().toArray(function(err, items) {
// test.ok(err == null);
// test.equal(1, items.length);
//
// db1.collection('stuff', function(err, collection) {
// collection.insert({a:2}, {safe:true}, self.parallel());
// });
//
// db2.collection('stuff', function(err, collection) {
// collection.insert({a:2}, {safe:true}, self.parallel());
// });
// })
// });
// },
//
// function logoutDb1(err, result1, result2) {
// test.ok(err == null);
// test.ok(result1 != null);
// test.ok(result2 != null);
//
// db1.logout(this);
// },
//
// function insertShouldFail(err, result) {
// var self = this;
// db1.collection('stuff', function(err, collection) {
// collection.insert({a:2}, {safe:true}, self.parallel());
// });
// },
//
// function logoutDb2(err, result) {
// test.ok(err != null);
// db2.logout(this);
// },
//
// function insertShouldFail(err, result) {
// var self = this;
// db2.collection('stuff', function(err, collection) {
// collection.insert({a:2}, {safe:true}, function(err, result) {
// test.ok(err != null);
// test.done();
// // Close all connections
// db1.close();
// db2.close();
// admin.close();
// });
// });
// }
// )
shouldCorrectlyInsertKillServerFailThenRestartServerAndSucceed : function(test) {
var db = new Db('test-single-server-recovery', new Server("127.0.0.1", 27017, {auto_reconnect: true}), {numberOfRetries:3, retryMiliSeconds:500, native_parser: (process.env['TEST_NATIVE'] != null)});
// All inserted docs
var docs = [];
var errs = [];
var insertDocs = [];
// Start server
serverManager = new ServerManager({auth:false, purgedirectories:true, journal:true})
serverManager.start(true, function() {
db.open(function(err, db) {
// Add an error handler
db.on("error", function(err) {
console.log("----------------------------------------------- received error")
console.dir(err)
errs.push(err);
});
db.collection('inserts', function(err, collection) {
var doc = {timestamp:new Date().getTime(), a:1};
collection.insert(doc, {safe:true}, function(err, result) {
test.equal(null, err);
// Kill server instance
serverManager.stop(9, function(err, result) {
// Attemp insert (should timeout)
var doc = {timestamp:new Date().getTime(), b:1};
collection.insert(doc, {safe:true}, function(err, result) {
test.ok(err != null);
test.equal(null, result);
// Restart server
serverManager = new ServerManager({auth:false, purgedirectories:false, journal:true});
serverManager.start(true, function() {
// Attemp insert again
collection.insert(doc, {safe:true}, function(err, result) {
// Fetch the documents
collection.find({b:1}).toArray(function(err, items) {
test.equal(null, err);
test.equal(1, items[0].b);
test.done();
});
});
});
});
});
})
});
});
});
},

@@ -257,0 +149,0 @@

Sorry, the diff of this file is not supported yet

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