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

diagnostic-channel-publishers

Package Overview
Dependencies
Maintainers
6
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

diagnostic-channel-publishers - npm Package Compare versions

Comparing version 0.3.2 to 0.3.3

0

dist/src/bunyan.pub.d.ts

@@ -0,0 +0,0 @@ import { IModulePatcher } from "diagnostic-channel";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { IModulePatcher } from "diagnostic-channel";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import * as bunyan from "./bunyan.pub";

@@ -0,0 +0,0 @@ "use strict";

import { IModulePatcher } from "diagnostic-channel";
export declare const mongoCore: IModulePatcher;
export declare function enable(): void;

@@ -0,0 +0,0 @@ "use strict";

1

dist/src/mongodb.pub.d.ts

@@ -17,2 +17,3 @@ import { IModulePatcher } from "diagnostic-channel";

export declare const mongo3: IModulePatcher;
export declare const mongo330: IModulePatcher;
export declare function enable(): void;

@@ -76,2 +76,69 @@ "use strict";

};
// In mongodb 3.3.0, mongodb-core was merged into mongodb, so the same patching
// can be used here. this.s.pool was changed to this.s.coreTopology.s.pool
var mongodbcorePatchFunction = function (originalMongo) {
var originalConnect = originalMongo.Server.prototype.connect;
originalMongo.Server.prototype.connect = function contextPreservingConnect() {
var ret = originalConnect.apply(this, arguments);
// Messages sent to mongo progress through a pool
// This can result in context getting mixed between different responses
// so we wrap the callbacks to restore appropriate state
var originalWrite = this.s.coreTopology.s.pool.write;
this.s.coreTopology.s.pool.write = function contextPreservingWrite() {
var cbidx = typeof arguments[1] === "function" ? 1 : 2;
if (typeof arguments[cbidx] === "function") {
arguments[cbidx] = diagnostic_channel_1.channel.bindToContext(arguments[cbidx]);
}
return originalWrite.apply(this, arguments);
};
// Logout is a special case, it doesn't call the write function but instead
// directly calls into connection.write
var originalLogout = this.s.coreTopology.s.pool.logout;
this.s.coreTopology.s.pool.logout = function contextPreservingLogout() {
if (typeof arguments[1] === "function") {
arguments[1] = diagnostic_channel_1.channel.bindToContext(arguments[1]);
}
return originalLogout.apply(this, arguments);
};
return ret;
};
return originalMongo;
};
var mongodb330PatchFunction = function (originalMongo) {
mongodbcorePatchFunction(originalMongo); // apply mongodb-core patches
var listener = originalMongo.instrument();
var eventMap = {};
var contextMap = {};
listener.on("started", function (event) {
if (eventMap[event.requestId]) {
// Note: Mongo can generate 2 completely separate requests
// which share the same requestId, if a certain race condition is triggered.
// For now, we accept that this can happen and potentially miss or mislabel some events.
return;
}
contextMap[event.requestId] = diagnostic_channel_1.channel.bindToContext(function (cb) { return cb(); });
eventMap[event.requestId] = event;
});
listener.on("succeeded", function (event) {
var startedData = eventMap[event.requestId];
if (startedData) {
delete eventMap[event.requestId];
}
if (typeof event === "object" && typeof contextMap[event.requestId] === "function") {
contextMap[event.requestId](function () { return diagnostic_channel_1.channel.publish("mongodb", { startedData: startedData, event: event, succeeded: true }); });
delete contextMap[event.requestId];
}
});
listener.on("failed", function (event) {
var startedData = eventMap[event.requestId];
if (startedData) {
delete eventMap[event.requestId];
}
if (typeof event === "object" && typeof contextMap[event.requestId] === "function") {
contextMap[event.requestId](function () { return diagnostic_channel_1.channel.publish("mongodb", { startedData: startedData, event: event, succeeded: false }); });
delete contextMap[event.requestId];
}
});
return originalMongo;
};
exports.mongo2 = {

@@ -82,10 +149,15 @@ versionSpecifier: ">= 2.0.0 <= 3.0.5",

exports.mongo3 = {
versionSpecifier: "> 3.0.5 < 4.0.0",
versionSpecifier: "> 3.0.5 < 3.3.0",
patch: mongodb3PatchFunction,
};
exports.mongo330 = {
versionSpecifier: ">= 3.3.0 < 4.0.0",
patch: mongodb330PatchFunction,
};
function enable() {
diagnostic_channel_1.channel.registerMonkeyPatch("mongodb", exports.mongo2);
diagnostic_channel_1.channel.registerMonkeyPatch("mongodb", exports.mongo3);
diagnostic_channel_1.channel.registerMonkeyPatch("mongodb", exports.mongo330);
}
exports.enable = enable;
//# sourceMappingURL=mongodb.pub.js.map

@@ -0,0 +0,0 @@ import { IModulePatcher } from "diagnostic-channel";

@@ -0,0 +0,0 @@ "use strict";

import { IModulePatcher } from "diagnostic-channel";
export declare const postgresPool1: IModulePatcher;
export declare function enable(): void;

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { IModulePatcher } from "diagnostic-channel";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { IModulePatcher } from "diagnostic-channel";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { IModulePatcher } from "diagnostic-channel";

@@ -0,0 +0,0 @@ "use strict";

2

package.json
{
"name": "diagnostic-channel-publishers",
"version": "0.3.2",
"version": "0.3.3",
"main": "dist/src/index.js",

@@ -5,0 +5,0 @@ "types": "dist/src/index.d.ts",

@@ -15,2 +15,5 @@ # Diagnostic Channel Publishers

## Release notes
### 0.3.3 - August 15, 2019
* Fix patching issue with new [mongodb@3.3.0+](https://github.com/mongodb/node-mongodb-native/releases/tag/v3.3.0) driver
### 0.3.2 - May 13, 2019

@@ -17,0 +20,0 @@ * Fix issue with colorized Winston logging levels

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