ml-testing-toolkit 18.16.0-snapshot.6 → 18.16.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/.ncurc.yaml +0 -1
- package/CHANGELOG.md +7 -0
- package/audit-ci.jsonc +1 -2
- package/package.json +5 -11
- package/src/lib/eventListenerClient/inboundEventListener.js +5 -24
- package/src/lib/scripting-engines/vm-javascript-sandbox.js +0 -3
- package/src/lib/webSocketClient/WebSocketClientManager.js +10 -12
package/.ncurc.yaml
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
# Changelog: [mojaloop/thirdparty-api-svc](https://github.com/mojaloop/thirdparty-api-svc)
|
|
2
|
+
## [18.16.0](https://github.com/mojaloop/ml-testing-toolkit/compare/v18.15.1...v18.16.0) (2025-09-16)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* **csi-1782:** fix MyEmitter memory leak ([#342](https://github.com/mojaloop/ml-testing-toolkit/issues/342)) ([c141048](https://github.com/mojaloop/ml-testing-toolkit/commit/c1410487a3c17824b0869b6920c2132d491a6007))
|
|
8
|
+
|
|
2
9
|
### [18.15.1](https://github.com/mojaloop/ml-testing-toolkit/compare/v18.15.0...v18.15.1) (2025-09-01)
|
|
3
10
|
|
|
4
11
|
|
package/audit-ci.jsonc
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ml-testing-toolkit",
|
|
3
3
|
"description": "Testing Toolkit for Mojaloop implementations",
|
|
4
|
-
"version": "18.16.0
|
|
4
|
+
"version": "18.16.0",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Vijaya Kumar Guthi, ModusBox Inc. ",
|
|
7
7
|
"contributors": [
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
],
|
|
41
41
|
"main": "src/index.js",
|
|
42
42
|
"scripts": {
|
|
43
|
-
"start": "node
|
|
43
|
+
"start": "node src/index.js",
|
|
44
44
|
"standard": "standard",
|
|
45
45
|
"standard:fix": "standard --fix",
|
|
46
46
|
"dev": "nodemon src/index.js",
|
|
@@ -80,15 +80,15 @@
|
|
|
80
80
|
"@hapi/vision": "7.0.3",
|
|
81
81
|
"@mojaloop/central-services-logger": "11.9.3",
|
|
82
82
|
"@mojaloop/central-services-metrics": "12.7.1",
|
|
83
|
-
"@mojaloop/ml-schema-transformer-lib": "2.7.
|
|
83
|
+
"@mojaloop/ml-schema-transformer-lib": "2.7.8",
|
|
84
84
|
"@mojaloop/ml-testing-toolkit-shared-lib": "14.2.0",
|
|
85
|
-
"@mojaloop/sdk-standard-components": "19.
|
|
85
|
+
"@mojaloop/sdk-standard-components": "19.17.0",
|
|
86
86
|
"@now-ims/hapi-now-auth": "2.1.0",
|
|
87
87
|
"@types/socket.io": "3.0.2",
|
|
88
88
|
"adm-zip": "0.5.16",
|
|
89
89
|
"ajv-formats": "3.0.1",
|
|
90
90
|
"atob": "2.1.2",
|
|
91
|
-
"axios": "1.12.
|
|
91
|
+
"axios": "1.12.2",
|
|
92
92
|
"chai": "4.4.1",
|
|
93
93
|
"connection-string": "^5.0.0",
|
|
94
94
|
"cookie-parser": "1.4.7",
|
|
@@ -194,12 +194,6 @@
|
|
|
194
194
|
"yargs-parser": "21.1.1",
|
|
195
195
|
"oas-validator": {
|
|
196
196
|
"ajv": "6.12.3"
|
|
197
|
-
},
|
|
198
|
-
"@mojaloop/central-services-shared": {
|
|
199
|
-
"axios": "1.12.0"
|
|
200
|
-
},
|
|
201
|
-
"@mojaloop/sdk-standard-components": {
|
|
202
|
-
"axios": "1.12.0"
|
|
203
197
|
}
|
|
204
198
|
}
|
|
205
199
|
}
|
|
@@ -27,9 +27,6 @@
|
|
|
27
27
|
--------------
|
|
28
28
|
******/
|
|
29
29
|
|
|
30
|
-
// Ignore temporarily to get the snapshot release done
|
|
31
|
-
/* istanbul ignore file */
|
|
32
|
-
|
|
33
30
|
const MyEventEmitter = require('../MyEventEmitter')
|
|
34
31
|
const EventEmitter = require('events')
|
|
35
32
|
class MyEmitter extends EventEmitter {}
|
|
@@ -46,17 +43,17 @@ class InboundEventListener {
|
|
|
46
43
|
this.consoleFn = console
|
|
47
44
|
}
|
|
48
45
|
this.emitter = MyEventEmitter.getEmitter('inboundRequest')
|
|
49
|
-
this.newInboundHandler = null
|
|
50
46
|
}
|
|
51
47
|
|
|
52
48
|
async init () {
|
|
53
49
|
this.userConfig = await Config.getStoredUserConfig()
|
|
54
50
|
|
|
55
|
-
|
|
56
|
-
|
|
51
|
+
// Fixes the MyEmitter listener leak issue
|
|
52
|
+
if (this.emitter.listenerCount('newInbound') > 0) {
|
|
53
|
+
this.emitter.removeAllListeners('newInbound')
|
|
57
54
|
}
|
|
58
55
|
|
|
59
|
-
this.
|
|
56
|
+
this.emitter.on('newInbound', (data) => {
|
|
60
57
|
for (const [, eventListener] of Object.entries(this.eventListeners)) {
|
|
61
58
|
// Match method, path and condition for each inbound request
|
|
62
59
|
if (eventListener.method === data.method && eventListener.path === data.path) {
|
|
@@ -70,9 +67,7 @@ class InboundEventListener {
|
|
|
70
67
|
}
|
|
71
68
|
}
|
|
72
69
|
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
this.emitter.on('newInbound', this.newInboundHandler)
|
|
70
|
+
})
|
|
76
71
|
}
|
|
77
72
|
|
|
78
73
|
customLog (logMessage) {
|
|
@@ -195,20 +190,6 @@ class InboundEventListener {
|
|
|
195
190
|
}
|
|
196
191
|
return true
|
|
197
192
|
}
|
|
198
|
-
|
|
199
|
-
// Add a new cleanup method
|
|
200
|
-
cleanup () {
|
|
201
|
-
// Remove the newInbound listener
|
|
202
|
-
if (this.newInboundHandler) {
|
|
203
|
-
this.emitter.removeListener('newInbound', this.newInboundHandler)
|
|
204
|
-
this.newInboundHandler = null
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
// Clean up all event listeners
|
|
208
|
-
Object.keys(this.eventListeners).forEach(clientName => {
|
|
209
|
-
this.destroy(clientName)
|
|
210
|
-
})
|
|
211
|
-
}
|
|
212
193
|
}
|
|
213
194
|
|
|
214
195
|
module.exports = {
|
|
@@ -265,9 +265,6 @@ const executeAsync = async (script, data, contextObj) => {
|
|
|
265
265
|
}
|
|
266
266
|
consoleLog.push([{ execution: 0 }, 'executionError', err.toString()])
|
|
267
267
|
}
|
|
268
|
-
// finally {
|
|
269
|
-
// contextObj.inboundEvent.cleanup()
|
|
270
|
-
// }
|
|
271
268
|
const result = {
|
|
272
269
|
consoleLog,
|
|
273
270
|
environment: { ...contextObj.environment }
|
|
@@ -28,9 +28,6 @@
|
|
|
28
28
|
--------------
|
|
29
29
|
******/
|
|
30
30
|
|
|
31
|
-
// Ignore temporarily to get the snapshot release done
|
|
32
|
-
/* istanbul ignore file */
|
|
33
|
-
|
|
34
31
|
const WebSocket = require('ws')
|
|
35
32
|
const EventEmitter = require('events')
|
|
36
33
|
class MyEmitter extends EventEmitter {}
|
|
@@ -56,6 +53,8 @@ class WebSocketClientManager {
|
|
|
56
53
|
}
|
|
57
54
|
|
|
58
55
|
connect (url, clientName, timeout = 15000) {
|
|
56
|
+
this.customLog(`Connecting to WebSocket URL: ${url} with client name: ${clientName} and timeout: ${timeout}ms`)
|
|
57
|
+
|
|
59
58
|
const tlsOptions = { rejectUnauthorized: false }
|
|
60
59
|
const urlObject = new URL(url)
|
|
61
60
|
if (this.userConfig.CLIENT_MUTUAL_TLS_ENABLED) {
|
|
@@ -165,7 +164,10 @@ class WebSocketClientManager {
|
|
|
165
164
|
|
|
166
165
|
disconnect (clientName) {
|
|
167
166
|
if (this.ws[clientName]) {
|
|
168
|
-
this.ws[clientName].client
|
|
167
|
+
if (this.ws[clientName].client) {
|
|
168
|
+
this.ws[clientName].client.removeAllListeners()
|
|
169
|
+
this.ws[clientName].client.close()
|
|
170
|
+
}
|
|
169
171
|
if (this.ws[clientName].eventEmitter) {
|
|
170
172
|
this.ws[clientName].eventEmitter.removeAllListeners()
|
|
171
173
|
}
|
|
@@ -180,7 +182,10 @@ class WebSocketClientManager {
|
|
|
180
182
|
|
|
181
183
|
disconnectAll () {
|
|
182
184
|
for (const clientName in this.ws) {
|
|
183
|
-
this.ws[clientName].client
|
|
185
|
+
if (this.ws[clientName].client) {
|
|
186
|
+
this.ws[clientName].client.removeAllListeners()
|
|
187
|
+
this.ws[clientName].client.close()
|
|
188
|
+
}
|
|
184
189
|
if (this.ws[clientName].eventEmitter) {
|
|
185
190
|
this.ws[clientName].eventEmitter.removeAllListeners()
|
|
186
191
|
}
|
|
@@ -193,13 +198,6 @@ class WebSocketClientManager {
|
|
|
193
198
|
}
|
|
194
199
|
return true
|
|
195
200
|
}
|
|
196
|
-
|
|
197
|
-
clearAllTimers () {
|
|
198
|
-
Object.keys(this.timers).forEach((clientName) => {
|
|
199
|
-
clearTimeout(this.timers[clientName])
|
|
200
|
-
delete this.timers[clientName]
|
|
201
|
-
})
|
|
202
|
-
}
|
|
203
201
|
}
|
|
204
202
|
|
|
205
203
|
module.exports = {
|