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

mongodb-core

Package Overview
Dependencies
Maintainers
3
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 3.0.5 to 3.0.6

.evergreen/config.yml

24

HISTORY.md

@@ -0,1 +1,25 @@

<a name="3.0.6"></a>
## [3.0.6](https://github.com/mongodb-js/mongodb-core/compare/v3.0.5...v3.0.6) (2018-04-09)
### Bug Fixes
* **2.6-protocol:** kill cursor callback is called by pool now ([65f2bf7](https://github.com/mongodb-js/mongodb-core/commit/65f2bf7))
* **evergreen:** change name to id ([9303e12](https://github.com/mongodb-js/mongodb-core/commit/9303e12))
* **evergreen:** change nvm path to local ([e42ea5b](https://github.com/mongodb-js/mongodb-core/commit/e42ea5b))
* **evergreen:** pass in flag through npm scripts ([85708dd](https://github.com/mongodb-js/mongodb-core/commit/85708dd))
* **pool:** ensure noResponse callback is only called if cb exists ([5281605](https://github.com/mongodb-js/mongodb-core/commit/5281605))
* **replset:** only remove primary if primary is there ([1acd288](https://github.com/mongodb-js/mongodb-core/commit/1acd288))
* **test-environments:** ensure all servers run on separate ports ([b63e5d8](https://github.com/mongodb-js/mongodb-core/commit/b63e5d8))
* **uri_parser:** support a default database on mongodb+srv uris ([be01ffe](https://github.com/mongodb-js/mongodb-core/commit/be01ffe))
### Features
* **apm:** add events for command monitoring support in core ([37dce9c](https://github.com/mongodb-js/mongodb-core/commit/37dce9c))
* **evergreen:** add evergreen config based on drivers skeleton ([b71da99](https://github.com/mongodb-js/mongodb-core/commit/b71da99))
* **evergreen:** use evergreen flag when running tests ([55dff3b](https://github.com/mongodb-js/mongodb-core/commit/55dff3b))
<a name="3.0.5"></a>

@@ -2,0 +26,0 @@ ## [3.0.5](https://github.com/mongodb-js/mongodb-core/compare/v3.0.4...v3.0.5) (2018-03-14)

6

lib/connection/commands.js

@@ -56,2 +56,5 @@ 'use strict';

// special case for pre-3.2 find commands, delete ASAP
this.pre32Limit = options.pre32Limit;
// Serialization option

@@ -319,3 +322,4 @@ this.serializeFunctions =

**************************************************************/
var KillCursor = function(bson, cursorIds) {
var KillCursor = function(bson, ns, cursorIds) {
this.ns = ns;
this.requestId = _requestId++;

@@ -322,0 +326,0 @@ this.cursorIds = cursorIds;

@@ -19,2 +19,4 @@ 'use strict';

const apm = require('./apm');
var MongoCR = require('../auth/mongocr'),

@@ -214,2 +216,3 @@ X509 = require('../auth/x509'),

if (legalStates && legalStates.indexOf(newState) !== -1) {
self.emit('stateChanged', self.state, newState);
self.state = newState;

@@ -1231,2 +1234,34 @@ } else {

// If command monitoring is enabled we need to modify the callback here
if (self.options.monitorCommands) {
// NOTE: there is only ever a single command, for some legacy reason I am unaware of we
// treat this as a potential array of commands
const command = commands[0];
this.emit('commandStarted', new apm.CommandStartedEvent(this, command));
operation.started = process.hrtime();
operation.cb = (err, reply) => {
if (err) {
self.emit(
'commandFailed',
new apm.CommandFailedEvent(this, command, err, operation.started)
);
} else {
if (reply && reply.result && (reply.result.ok === 0 || reply.result.$err)) {
self.emit(
'commandFailed',
new apm.CommandFailedEvent(this, command, reply.result, operation.started)
);
} else {
self.emit(
'commandSucceeded',
new apm.CommandSucceededEvent(this, command, reply, operation.started)
);
}
}
if (typeof cb === 'function') cb(err, reply);
};
}
// Prepare the operation buffer

@@ -1541,2 +1576,7 @@ serializeCommands(self, commands, [], function(err, serializedCommands) {

// if the command is designated noResponse, call the callback immeditely
if (workItem.noResponse && typeof workItem.cb === 'function') {
workItem.cb(null, null);
}
if (writeSuccessful && workItem.immediateRelease && self.authenticating) {

@@ -1543,0 +1583,0 @@ removeConnection(self, connection);

44

lib/cursor.js

@@ -356,25 +356,2 @@ 'use strict';

Cursor.prototype._killcursor = function(callback) {
// Set cursor to dead
this.cursorState.dead = true;
this.cursorState.killed = true;
// Remove documents
this.cursorState.documents = [];
// If no cursor id just return
if (
this.cursorState.cursorId == null ||
this.cursorState.cursorId.isZero() ||
this.cursorState.init === false
) {
if (callback) callback(null, null);
return;
}
// Default pool
var pool = this.server.s.pool;
// Execute command
this.server.wireProtocolHandler.killCursor(this.bson, this.ns, this.cursorState, pool, callback);
};
/**

@@ -470,3 +447,22 @@ * Clone the cursor

Cursor.prototype.kill = function(callback) {
this._killcursor(callback);
// Set cursor to dead
this.cursorState.dead = true;
this.cursorState.killed = true;
// Remove documents
this.cursorState.documents = [];
// If no cursor id just return
if (
this.cursorState.cursorId == null ||
this.cursorState.cursorId.isZero() ||
this.cursorState.init === false
) {
if (callback) callback(null, null);
return;
}
// Default pool
var pool = this.server.s.pool;
// Execute command
this.server.wireProtocolHandler.killCursor(this.bson, this.ns, this.cursorState, pool, callback);
};

@@ -473,0 +469,0 @@

@@ -18,3 +18,4 @@ 'use strict';

isRetryableWritesSupported = require('./shared').isRetryableWritesSupported,
getNextTransactionNumber = require('./shared').getNextTransactionNumber;
getNextTransactionNumber = require('./shared').getNextTransactionNumber,
relayEvents = require('./shared').relayEvents;

@@ -115,2 +116,3 @@ const BSON = retrieveBSON();

* @param {boolean} [options.domainsEnabled=false] Enable the wrapping of the callback in the current domain, disabled by default to avoid perf hit.
* @param {boolean} [options.monitorCommands=false] Enable command monitoring for this topology
* @return {Mongos} A cursor instance

@@ -472,2 +474,6 @@ * @fires Mongos#connect

server.once('connect', handleInitialConnectEvent(self, 'connect'));
// Command Monitoring events
relayEvents(server, self, ['commandStarted', 'commandSucceeded', 'commandFailed']);
// Start connection

@@ -645,2 +651,5 @@ server.connect(self.s.connectOptions);

// Command Monitoring events
relayEvents(server, self, ['commandStarted', 'commandSucceeded', 'commandFailed']);
// Connect to proxy

@@ -1456,2 +1465,23 @@ server.connect(self.s.connectOptions);

/**
* An event emitted indicating a command was started, if command monitoring is enabled
*
* @event Mongos#commandStarted
* @type {object}
*/
/**
* An event emitted indicating a command succeeded, if command monitoring is enabled
*
* @event Mongos#commandSucceeded
* @type {object}
*/
/**
* An event emitted indicating a command failed, if command monitoring is enabled
*
* @event Mongos#commandFailed
* @type {object}
*/
module.exports = Mongos;

@@ -20,3 +20,4 @@ 'use strict';

isRetryableWritesSupported = require('./shared').isRetryableWritesSupported,
getNextTransactionNumber = require('./shared').getNextTransactionNumber;
getNextTransactionNumber = require('./shared').getNextTransactionNumber,
relayEvents = require('./shared').relayEvents;

@@ -102,2 +103,3 @@ var MongoCR = require('../auth/mongocr'),

* @param {boolean} [options.domainsEnabled=false] Enable the wrapping of the callback in the current domain, disabled by default to avoid perf hit.
* @param {boolean} [options.monitorCommands=false] Enable command monitoring for this topology
* @return {ReplSet} A cursor instance

@@ -407,11 +409,9 @@ * @fires ReplSet#connect

// SDAM Monitoring events
server.on('serverOpening', function(e) {
self.emit('serverOpening', e);
});
server.on('serverDescriptionChanged', function(e) {
self.emit('serverDescriptionChanged', e);
});
server.on('serverClosed', function(e) {
self.emit('serverClosed', e);
});
server.on('serverOpening', e => self.emit('serverOpening', e));
server.on('serverDescriptionChanged', e => self.emit('serverDescriptionChanged', e));
server.on('serverClosed', e => self.emit('serverClosed', e));
// Command Monitoring events
relayEvents(server, self, ['commandStarted', 'commandSucceeded', 'commandFailed']);
server.connect(self.s.connectOptions);

@@ -940,12 +940,11 @@ }, i);

server.once('connect', handleInitialConnectEvent(self, 'connect'));
// SDAM Monitoring events
server.on('serverOpening', function(e) {
self.emit('serverOpening', e);
});
server.on('serverDescriptionChanged', function(e) {
self.emit('serverDescriptionChanged', e);
});
server.on('serverClosed', function(e) {
self.emit('serverClosed', e);
});
server.on('serverOpening', e => self.emit('serverOpening', e));
server.on('serverDescriptionChanged', e => self.emit('serverDescriptionChanged', e));
server.on('serverClosed', e => self.emit('serverClosed', e));
// Command Monitoring events
relayEvents(server, self, ['commandStarted', 'commandSucceeded', 'commandFailed']);
// Start connection

@@ -1225,3 +1224,5 @@ server.connect(self.s.connectOptions);

// Per SDAM, remove primary from replicaset
self.s.replicaSetState.remove(self.s.replicaSetState.primary, { force: true });
if (self.s.replicaSetState.primary) {
self.s.replicaSetState.remove(self.s.replicaSetState.primary, { force: true });
}

@@ -1679,2 +1680,23 @@ return callback(err);

/**
* An event emitted indicating a command was started, if command monitoring is enabled
*
* @event ReplSet#commandStarted
* @type {object}
*/
/**
* An event emitted indicating a command succeeded, if command monitoring is enabled
*
* @event ReplSet#commandSucceeded
* @type {object}
*/
/**
* An event emitted indicating a command failed, if command monitoring is enabled
*
* @event ReplSet#commandFailed
* @type {object}
*/
module.exports = ReplSet;

@@ -21,3 +21,4 @@ 'use strict';

resolveClusterTime = require('./shared').resolveClusterTime,
SessionMixins = require('./shared').SessionMixins;
SessionMixins = require('./shared').SessionMixins,
relayEvents = require('./shared').relayEvents;

@@ -90,2 +91,3 @@ // Used for filtering out fields for loggin

* @param {boolean} [options.domainsEnabled=false] Enable the wrapping of the callback in the current domain, disabled by default to avoid perf hit.
* @param {boolean} [options.monitorCommands=false] Enable command monitoring for this topology
* @return {Server} A cursor instance

@@ -560,2 +562,5 @@ * @fires Server#connect

// Set up listeners for command monitoring
relayEvents(self.s.pool, self, ['commandStarted', 'commandSucceeded', 'commandFailed']);
// Emit toplogy opening event if not in topology

@@ -562,0 +567,0 @@ if (!self.s.inTopology) {

@@ -433,2 +433,12 @@ 'use strict';

/**
* Relays events for a given listener and emitter
*
* @param {EventEmitter} listener the EventEmitter to listen to the events for
* @param {EventEmitter} emitter the EventEmitter to relay the events on
*/
function relayEvents(listener, emitter, events) {
events.forEach(eventName => listener.on(eventName, event => emitter.emit(eventName, event)));
}
module.exports.SessionMixins = SessionMixins;

@@ -449,1 +459,2 @@ module.exports.resolveClusterTime = resolveClusterTime;

module.exports.getNextTransactionNumber = getNextTransactionNumber;
module.exports.relayEvents = relayEvents;

@@ -74,5 +74,15 @@ 'use strict';

let connectionString = connectionStrings.join(',') + '/';
let connectionString = `${connectionStrings.join(',')}/`;
let connectionStringOptions = [];
// Add the default database if needed
if (result.path) {
let defaultDb = result.path.slice(1);
if (defaultDb.indexOf('?') !== -1) {
defaultDb = defaultDb.slice(0, defaultDb.indexOf('?'));
}
connectionString += defaultDb;
}
// Default to SSL true

@@ -79,0 +89,0 @@ if (!options.ssl && (!result.search || result.query['ssl'] == null)) {

@@ -90,3 +90,3 @@ 'use strict';

// Create a kill cursor command
var killCursor = new KillCursor(bson, [cursorId]);
var killCursor = new KillCursor(bson, ns, [cursorId]);

@@ -108,8 +108,9 @@ // Build killCursor options

} catch (err) {
callback(err, null);
if (typeof callback === 'function') {
callback(err, null);
} else {
console.warn(err);
}
}
}
// Callback
if (typeof callback === 'function') callback(null, null);
};

@@ -221,4 +222,2 @@

var findCmd = {};
// Using special modifier
var usesSpecialModifier = false;

@@ -228,16 +227,15 @@ // We have a Mongos topology, check if we need to add a readPreference

findCmd['$readPreference'] = readPreference.toJSON();
usesSpecialModifier = true;
}
// Add special modifiers to the query
if (cmd.sort) (findCmd['orderby'] = cmd.sort), (usesSpecialModifier = true);
if (cmd.hint) (findCmd['$hint'] = cmd.hint), (usesSpecialModifier = true);
if (cmd.snapshot) (findCmd['$snapshot'] = cmd.snapshot), (usesSpecialModifier = true);
if (cmd.returnKey) (findCmd['$returnKey'] = cmd.returnKey), (usesSpecialModifier = true);
if (cmd.maxScan) (findCmd['$maxScan'] = cmd.maxScan), (usesSpecialModifier = true);
if (cmd.min) (findCmd['$min'] = cmd.min), (usesSpecialModifier = true);
if (cmd.max) (findCmd['$max'] = cmd.max), (usesSpecialModifier = true);
if (cmd.showDiskLoc) (findCmd['$showDiskLoc'] = cmd.showDiskLoc), (usesSpecialModifier = true);
if (cmd.comment) (findCmd['$comment'] = cmd.comment), (usesSpecialModifier = true);
if (cmd.maxTimeMS) (findCmd['$maxTimeMS'] = cmd.maxTimeMS), (usesSpecialModifier = true);
if (cmd.sort) findCmd['$orderby'] = cmd.sort;
if (cmd.hint) findCmd['$hint'] = cmd.hint;
if (cmd.snapshot) findCmd['$snapshot'] = cmd.snapshot;
if (typeof cmd.returnKey !== 'undefined') findCmd['$returnKey'] = cmd.returnKey;
if (cmd.maxScan) findCmd['$maxScan'] = cmd.maxScan;
if (cmd.min) findCmd['$min'] = cmd.min;
if (cmd.max) findCmd['$max'] = cmd.max;
if (typeof cmd.showDiskLoc !== 'undefined') findCmd['$showDiskLoc'] = cmd.showDiskLoc;
if (cmd.comment) findCmd['$comment'] = cmd.comment;
if (cmd.maxTimeMS) findCmd['$maxTimeMS'] = cmd.maxTimeMS;

@@ -248,12 +246,7 @@ if (cmd.explain) {

numberToReturn = -Math.abs(cmd.limit || 0);
usesSpecialModifier = true;
findCmd['$explain'] = true;
}
// If we have a special modifier
if (usesSpecialModifier) {
findCmd['$query'] = cmd.query;
} else {
findCmd = cmd.query;
}
// Add the query
findCmd['$query'] = cmd.query;

@@ -283,2 +276,3 @@ // Throw on majority readConcern passed in

numberToReturn: numberToReturn,
pre32Limit: typeof cmd.limit !== 'undefined' ? cmd.limit : undefined,
checkKeys: false,

@@ -285,0 +279,0 @@ returnFieldSelector: cmd.fields,

@@ -472,6 +472,6 @@ 'use strict';

// If we have returnKey set
if (cmd.returnKey) findCmd.returnKey = cmd.returnKey;
findCmd.returnKey = cmd.returnKey ? cmd.returnKey : false;
// If we have showDiskLoc set
if (cmd.showDiskLoc) findCmd.showRecordId = cmd.showDiskLoc;
findCmd.showRecordId = cmd.showDiskLoc ? cmd.showDiskLoc : false;

@@ -478,0 +478,0 @@ // If we have snapshot set

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

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

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