1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.enable = exports.mongoCore = void 0;
|
4 |
|
5 |
|
6 | var diagnostic_channel_1 = require("diagnostic-channel");
|
7 | var mongodbcorePatchFunction = function (originalMongoCore) {
|
8 | var originalConnect = originalMongoCore.Server.prototype.connect;
|
9 | originalMongoCore.Server.prototype.connect = function contextPreservingConnect() {
|
10 | var ret = originalConnect.apply(this, arguments);
|
11 |
|
12 |
|
13 |
|
14 | var originalWrite = this.s.pool.write;
|
15 | this.s.pool.write = function contextPreservingWrite() {
|
16 | var cbidx = typeof arguments[1] === "function" ? 1 : 2;
|
17 | if (typeof arguments[cbidx] === "function") {
|
18 | arguments[cbidx] = diagnostic_channel_1.channel.bindToContext(arguments[cbidx]);
|
19 | }
|
20 | return originalWrite.apply(this, arguments);
|
21 | };
|
22 |
|
23 |
|
24 | var originalLogout = this.s.pool.logout;
|
25 | this.s.pool.logout = function contextPreservingLogout() {
|
26 | if (typeof arguments[1] === "function") {
|
27 | arguments[1] = diagnostic_channel_1.channel.bindToContext(arguments[1]);
|
28 | }
|
29 | return originalLogout.apply(this, arguments);
|
30 | };
|
31 | return ret;
|
32 | };
|
33 | return originalMongoCore;
|
34 | };
|
35 | exports.mongoCore = {
|
36 | versionSpecifier: ">= 2.0.0 < 4.0.0",
|
37 | patch: mongodbcorePatchFunction
|
38 | };
|
39 | function enable() {
|
40 | diagnostic_channel_1.channel.registerMonkeyPatch("mongodb-core", exports.mongoCore);
|
41 | }
|
42 | exports.enable = enable;
|
43 |
|
\ | No newline at end of file |