@5minds/node-red-contrib-processcube 1.16.1-develop-136f5e-mh90amev → 1.16.1-develop-c6444b-mhvwu80i
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/externaltask-input.js +54 -46
- package/package.json +1 -1
package/externaltask-input.js
CHANGED
|
@@ -29,15 +29,15 @@ module.exports = function (RED) {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
if (!options['lockDuration'] && (process.env.NODE_RED_ETW_LOCK_DURATION || process.env.NODERED_ETW_LOCK_DURATION)) {
|
|
32
|
-
options['lockDuration'] = parseInt(process.env.NODE_RED_ETW_LOCK_DURATION
|
|
32
|
+
options['lockDuration'] = parseInt(process.env.NODE_RED_ETW_LOCK_DURATION || process.env.NODERED_ETW_LOCK_DURATION) || undefined;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
if (!options['longpollingTimeout']) {
|
|
36
|
-
options['longpollingTimeout'] = parseInt(process.env.NODE_RED_ETW_LONGPOLLING_TIMEOUT
|
|
36
|
+
options['longpollingTimeout'] = parseInt(process.env.NODE_RED_ETW_LONGPOLLING_TIMEOUT || process.env.NODERED_ETW_LONGPOLLING_TIMEOUT) || undefined;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
if (!options['idleTimeout']) {
|
|
40
|
-
options['idleTimeout'] = parseInt(process.env.NODE_RED_ETW_IDLE_TIMEOUT
|
|
40
|
+
options['idleTimeout'] = parseInt(process.env.NODE_RED_ETW_IDLE_TIMEOUT || process.env.NODERED_ETW_IDLE_TIMEOUT) || undefined;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
node._subscribed = true;
|
|
@@ -165,60 +165,68 @@ module.exports = function (RED) {
|
|
|
165
165
|
};
|
|
166
166
|
|
|
167
167
|
const onPreDeliver = (sendEvent) => {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
const sourceNode = sendEvent?.source?.node;
|
|
171
|
-
const destinationNode = sendEvent?.destination?.node;
|
|
168
|
+
try {
|
|
169
|
+
if (node.isHandling() && node.ownMessage(sendEvent.msg)) {
|
|
172
170
|
|
|
173
|
-
|
|
171
|
+
const sourceNode = sendEvent?.source?.node;
|
|
172
|
+
const destinationNode = sendEvent?.destination?.node;
|
|
174
173
|
|
|
175
|
-
|
|
174
|
+
node._step = `${destinationNode.name || destinationNode.type}`;
|
|
176
175
|
|
|
177
|
-
|
|
178
|
-
event: 'enter',
|
|
179
|
-
sourceName: sourceNode.name,
|
|
180
|
-
sourceType: sourceNode.type,
|
|
181
|
-
destinationNodeName: destinationNode.name,
|
|
182
|
-
destinationNodeType: destinationNode.type,
|
|
183
|
-
timestamp: new Date().toISOString(),
|
|
184
|
-
};
|
|
176
|
+
node.showStatus();
|
|
185
177
|
|
|
186
|
-
|
|
178
|
+
const debugMsg = {
|
|
179
|
+
event: 'enter',
|
|
180
|
+
sourceName: sourceNode.name,
|
|
181
|
+
sourceType: sourceNode.type,
|
|
182
|
+
destinationNodeName: destinationNode.name,
|
|
183
|
+
destinationNodeType: destinationNode.type,
|
|
184
|
+
timestamp: new Date().toISOString(),
|
|
185
|
+
};
|
|
187
186
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
187
|
+
node.traceExecution(debugMsg);
|
|
188
|
+
|
|
189
|
+
if (process.env.NODE_RED_ETW_STEP_LOGGING == 'true' || process.env.NODERED_ETW_STEP_LOGGING == 'true') {
|
|
190
|
+
node._trace = `'${sourceNode.name || sourceNode.type}'->'${destinationNode.name || destinationNode.type}'`;
|
|
191
|
+
node.log(`preDeliver: ${node._trace}`);
|
|
192
|
+
}
|
|
191
193
|
}
|
|
194
|
+
} catch (error) {
|
|
195
|
+
node.error(`Error in onPreDeliver: ${error?.message}`, { error: error });
|
|
192
196
|
}
|
|
193
197
|
};
|
|
194
|
-
RED.hooks.add(
|
|
198
|
+
RED.hooks.add(`preDeliver.etw-input-${node.id}`, onPreDeliver);
|
|
195
199
|
|
|
196
200
|
const onPostDeliver = (sendEvent) => {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
201
|
+
try {
|
|
202
|
+
if (node.isHandling() && node.ownMessage(sendEvent.msg)) {
|
|
203
|
+
const sourceNode = sendEvent?.source?.node;
|
|
204
|
+
const destinationNode = sendEvent?.destination?.node;
|
|
205
|
+
|
|
206
|
+
node.decrMsgOnNode(sourceNode, sendEvent.msg);
|
|
207
|
+
node.incMsgOnNode(destinationNode, sendEvent.msg);
|
|
208
|
+
|
|
209
|
+
const debugMsg = {
|
|
210
|
+
event: 'exit',
|
|
211
|
+
sourceName: sourceNode.name,
|
|
212
|
+
sourceType: sourceNode.type,
|
|
213
|
+
destinationNodeName: destinationNode.name,
|
|
214
|
+
destinationNodeType: destinationNode.type,
|
|
215
|
+
timestamp: new Date().toISOString(),
|
|
216
|
+
};
|
|
212
217
|
|
|
213
|
-
|
|
218
|
+
node.traceExecution(debugMsg);
|
|
214
219
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
220
|
+
if (process.env.NODE_RED_ETW_STEP_LOGGING == 'true' || process.env.NODERED_ETW_STEP_LOGGING == 'true') {
|
|
221
|
+
node._trace = `'${sourceNode.name || sourceNode.type}'->'${destinationNode.name || destinationNode.type}'`;
|
|
222
|
+
node.log(`postDeliver: ${node._trace}`);
|
|
223
|
+
}
|
|
218
224
|
}
|
|
225
|
+
} catch (error) {
|
|
226
|
+
node.error(`Error in onPostDeliver: ${error?.message}`, { error: error });
|
|
219
227
|
}
|
|
220
228
|
};
|
|
221
|
-
RED.hooks.add(
|
|
229
|
+
RED.hooks.add(`postDeliver.etw-input-${node.id}`, onPostDeliver);
|
|
222
230
|
|
|
223
231
|
node.setSubscribedStatus = () => {
|
|
224
232
|
this._subscribed = true;
|
|
@@ -488,12 +496,12 @@ module.exports = function (RED) {
|
|
|
488
496
|
|
|
489
497
|
node.on('close', () => {
|
|
490
498
|
try {
|
|
491
|
-
RED.hooks.remove('preDeliver', onPreDeliver);
|
|
492
|
-
RED.hooks.remove('postDeliver', onPostDeliver);
|
|
493
499
|
externalTaskWorker.stop();
|
|
500
|
+
RED.hooks.remove(`preDeliver.etw-input-${node.id}`);
|
|
501
|
+
RED.hooks.remove(`postDeliver.etw-input-${node.id}`);
|
|
494
502
|
node.log('External Task Worker closed.');
|
|
495
|
-
} catch {
|
|
496
|
-
node.error(
|
|
503
|
+
} catch (error) {
|
|
504
|
+
node.error(`Client close failed: ${JSON.stringify(error)}`);
|
|
497
505
|
}
|
|
498
506
|
});
|
|
499
507
|
})
|