node-opcua-leak-detector 2.51.0 → 2.60.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +6 -6
- package/src/resource_leak_detector.js +26 -31
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-opcua-leak-detector",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.60.0",
|
|
4
4
|
"description": "pure nodejs OPCUA SDK - module -leak-detector",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"lint": "
|
|
7
|
+
"lint": "eslint src/**/*.js",
|
|
8
8
|
"clean": "node -e \"require('rimraf').sync('dist');\"",
|
|
9
9
|
"test": "echo no test"
|
|
10
10
|
},
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
"license": "MIT",
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"chalk": "4.1.2",
|
|
15
|
-
"node-opcua-assert": "2.
|
|
16
|
-
"node-opcua-debug": "2.
|
|
17
|
-
"node-opcua-object-registry": "2.
|
|
15
|
+
"node-opcua-assert": "2.55.0",
|
|
16
|
+
"node-opcua-debug": "2.60.0",
|
|
17
|
+
"node-opcua-object-registry": "2.60.0"
|
|
18
18
|
},
|
|
19
19
|
"repository": {
|
|
20
20
|
"type": "git",
|
|
@@ -29,5 +29,5 @@
|
|
|
29
29
|
"internet of things"
|
|
30
30
|
],
|
|
31
31
|
"homepage": "http://node-opcua.github.io/",
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "56dc8584b9118ee2f3bfb0b2e9d456b609ccbac8"
|
|
33
33
|
}
|
|
@@ -17,18 +17,17 @@ const monitor_intervals = false;
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
function ResourceLeakDetector() {
|
|
20
|
-
const self = this;
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
this.setIntervalCallCount = 0;
|
|
22
|
+
this.clearIntervalCallCount = 0;
|
|
24
23
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
this.setTimeoutCallCount = 0;
|
|
25
|
+
this.clearTimeoutCallCount = 0;
|
|
26
|
+
this.honoredTimeoutFuncCallCount = 0;
|
|
27
|
+
this.setTimeoutCallPendingCount = 0;
|
|
29
28
|
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
this.interval_map = {};
|
|
30
|
+
this.timeout_map = {};
|
|
32
31
|
}
|
|
33
32
|
|
|
34
33
|
/**
|
|
@@ -40,22 +39,20 @@ function ResourceLeakDetector() {
|
|
|
40
39
|
ResourceLeakDetector.prototype.verify_registry_counts = function(info) {
|
|
41
40
|
const errorMessages = [];
|
|
42
41
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
if (self.clearIntervalCallCount !== self.setIntervalCallCount) {
|
|
42
|
+
if (this.clearIntervalCallCount !== this.setIntervalCallCount) {
|
|
46
43
|
errorMessages.push(" setInterval doesn't match number of clearInterval calls : \n " +
|
|
47
|
-
" setIntervalCallCount = " +
|
|
48
|
-
" clearIntervalCallCount = " +
|
|
44
|
+
" setIntervalCallCount = " + this.setIntervalCallCount +
|
|
45
|
+
" clearIntervalCallCount = " + this.clearIntervalCallCount);
|
|
49
46
|
}
|
|
50
|
-
if ((
|
|
47
|
+
if ((this.clearTimeoutCallCount + this.honoredTimeoutFuncCallCount) !== this.setTimeoutCallCount) {
|
|
51
48
|
errorMessages.push(" setTimeout doesn't match number of clearTimeout or achieved timer calls : \n " +
|
|
52
|
-
" setTimeoutCallCount = " +
|
|
53
|
-
" clearTimeoutCallCount = " +
|
|
54
|
-
" honoredTimeoutFuncCallCount = " +
|
|
49
|
+
" setTimeoutCallCount = " + this.setTimeoutCallCount +
|
|
50
|
+
" clearTimeoutCallCount = " + this.clearTimeoutCallCount +
|
|
51
|
+
" honoredTimeoutFuncCallCount = " + this.honoredTimeoutFuncCallCount);
|
|
55
52
|
}
|
|
56
|
-
if (
|
|
53
|
+
if (this.setTimeoutCallPendingCount !== 0) {
|
|
57
54
|
errorMessages.push(" setTimeoutCallPendingCount is not zero: some timer are still pending " +
|
|
58
|
-
|
|
55
|
+
this.setTimeoutCallPendingCount);
|
|
59
56
|
}
|
|
60
57
|
|
|
61
58
|
const monitoredResource = ObjectRegistry.registries;
|
|
@@ -80,16 +77,16 @@ ResourceLeakDetector.prototype.verify_registry_counts = function(info) {
|
|
|
80
77
|
|
|
81
78
|
console.log("----------------------------------------------- more info");
|
|
82
79
|
|
|
83
|
-
console.log(chalk.cyan("test filename : "),
|
|
84
|
-
console.log(chalk.cyan("setInterval/clearInterval leaks : "), Object.entries(
|
|
85
|
-
for (const [key, value] of Object.entries(
|
|
80
|
+
console.log(chalk.cyan("test filename : "), this.ctx ? this.ctx.test.parent.file + " " + this.ctx.test.parent.title : "???");
|
|
81
|
+
console.log(chalk.cyan("setInterval/clearInterval leaks : "), Object.entries(this.interval_map).length);
|
|
82
|
+
for (const [key, value] of Object.entries(this.interval_map)) {
|
|
86
83
|
if (value && !value.disposed) {
|
|
87
84
|
console.log("key =", key, "value.disposed = ", value.disposed);
|
|
88
85
|
console.log(value.stack);//.split("\n"));
|
|
89
86
|
}
|
|
90
87
|
}
|
|
91
|
-
console.log(chalk.cyan("setTimeout/clearTimeout leaks : "), Object.entries(
|
|
92
|
-
for (const [key, value] of Object.entries(
|
|
88
|
+
console.log(chalk.cyan("setTimeout/clearTimeout leaks : "), Object.entries(this.timeout_map).length);
|
|
89
|
+
for (const [key, value] of Object.entries(this.timeout_map)) {
|
|
93
90
|
if (value && !value.disposed) {
|
|
94
91
|
console.log("setTimeout key =", key, "value.disposed = ", value.disposed);
|
|
95
92
|
console.log(value.stack);//.split("\n"));
|
|
@@ -118,6 +115,7 @@ ResourceLeakDetector.prototype.start = function(info) {
|
|
|
118
115
|
global.ResourceLeakDetectorStarted = true;
|
|
119
116
|
|
|
120
117
|
const self = ResourceLeakDetector.singleton;
|
|
118
|
+
|
|
121
119
|
if (trace) {
|
|
122
120
|
console.log(" starting resourceLeakDetector");
|
|
123
121
|
}
|
|
@@ -296,7 +294,7 @@ ResourceLeakDetector.prototype.start = function(info) {
|
|
|
296
294
|
};
|
|
297
295
|
|
|
298
296
|
ResourceLeakDetector.prototype.check = function() {
|
|
299
|
-
|
|
297
|
+
/** */
|
|
300
298
|
};
|
|
301
299
|
|
|
302
300
|
ResourceLeakDetector.prototype.stop = function(info) {
|
|
@@ -360,8 +358,7 @@ exports.installResourceLeakDetector = function(isGlobal, func) {
|
|
|
360
358
|
if (isGlobal) {
|
|
361
359
|
before(function() {
|
|
362
360
|
testHasFailed = false;
|
|
363
|
-
|
|
364
|
-
resourceLeakDetector.ctx = self.test.ctx;
|
|
361
|
+
resourceLeakDetector.ctx = this.test.ctx;
|
|
365
362
|
resourceLeakDetector.start();
|
|
366
363
|
// make sure we start with a garbage collected situation
|
|
367
364
|
if (global.gc) {
|
|
@@ -392,9 +389,7 @@ exports.installResourceLeakDetector = function(isGlobal, func) {
|
|
|
392
389
|
if (global.gc) {
|
|
393
390
|
global.gc(true);
|
|
394
391
|
}
|
|
395
|
-
|
|
396
|
-
const self = this;
|
|
397
|
-
resourceLeakDetector.ctx = self.test.ctx;
|
|
392
|
+
resourceLeakDetector.ctx = this.test.ctx;
|
|
398
393
|
resourceLeakDetector.start();
|
|
399
394
|
});
|
|
400
395
|
afterEach(function() {
|