@5minds/node-red-contrib-processcube 1.16.1-feature-91fab0-mhvqo2et → 1.16.1-feature-b8d70b-mhvx8c1e
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 +51 -43
- package/package.json +1 -1
package/externaltask-input.js
CHANGED
|
@@ -284,60 +284,68 @@ module.exports = function (RED) {
|
|
|
284
284
|
};
|
|
285
285
|
|
|
286
286
|
const onPreDeliver = (sendEvent) => {
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
const sourceNode = sendEvent?.source?.node;
|
|
290
|
-
const destinationNode = sendEvent?.destination?.node;
|
|
287
|
+
try {
|
|
288
|
+
if (node.isHandling() && node.ownMessage(sendEvent.msg)) {
|
|
291
289
|
|
|
292
|
-
|
|
290
|
+
const sourceNode = sendEvent?.source?.node;
|
|
291
|
+
const destinationNode = sendEvent?.destination?.node;
|
|
293
292
|
|
|
294
|
-
|
|
293
|
+
node._step = `${destinationNode.name || destinationNode.type}`;
|
|
295
294
|
|
|
296
|
-
|
|
297
|
-
event: 'enter',
|
|
298
|
-
sourceName: sourceNode.name,
|
|
299
|
-
sourceType: sourceNode.type,
|
|
300
|
-
destinationNodeName: destinationNode.name,
|
|
301
|
-
destinationNodeType: destinationNode.type,
|
|
302
|
-
timestamp: new Date().toISOString(),
|
|
303
|
-
};
|
|
295
|
+
node.showStatus();
|
|
304
296
|
|
|
305
|
-
|
|
297
|
+
const debugMsg = {
|
|
298
|
+
event: 'enter',
|
|
299
|
+
sourceName: sourceNode.name,
|
|
300
|
+
sourceType: sourceNode.type,
|
|
301
|
+
destinationNodeName: destinationNode.name,
|
|
302
|
+
destinationNodeType: destinationNode.type,
|
|
303
|
+
timestamp: new Date().toISOString(),
|
|
304
|
+
};
|
|
306
305
|
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
306
|
+
node.traceExecution(debugMsg);
|
|
307
|
+
|
|
308
|
+
if (process.env.NODE_RED_ETW_STEP_LOGGING == 'true' || process.env.NODERED_ETW_STEP_LOGGING == 'true') {
|
|
309
|
+
node._trace = `'${sourceNode.name || sourceNode.type}'->'${destinationNode.name || destinationNode.type}'`;
|
|
310
|
+
node.log(`preDeliver: ${node._trace}`);
|
|
311
|
+
}
|
|
310
312
|
}
|
|
313
|
+
} catch (error) {
|
|
314
|
+
node.error(`Error in onPreDeliver: ${error?.message}`, { error: error });
|
|
311
315
|
}
|
|
312
316
|
};
|
|
313
|
-
RED.hooks.add(
|
|
317
|
+
RED.hooks.add(`preDeliver.etw-input-${node.id}`, onPreDeliver);
|
|
314
318
|
|
|
315
319
|
const onPostDeliver = (sendEvent) => {
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
320
|
+
try {
|
|
321
|
+
if (node.isHandling() && node.ownMessage(sendEvent.msg)) {
|
|
322
|
+
const sourceNode = sendEvent?.source?.node;
|
|
323
|
+
const destinationNode = sendEvent?.destination?.node;
|
|
324
|
+
|
|
325
|
+
node.decrMsgOnNode(sourceNode, sendEvent.msg);
|
|
326
|
+
node.incMsgOnNode(destinationNode, sendEvent.msg);
|
|
327
|
+
|
|
328
|
+
const debugMsg = {
|
|
329
|
+
event: 'exit',
|
|
330
|
+
sourceName: sourceNode.name,
|
|
331
|
+
sourceType: sourceNode.type,
|
|
332
|
+
destinationNodeName: destinationNode.name,
|
|
333
|
+
destinationNodeType: destinationNode.type,
|
|
334
|
+
timestamp: new Date().toISOString(),
|
|
335
|
+
};
|
|
331
336
|
|
|
332
|
-
|
|
337
|
+
node.traceExecution(debugMsg);
|
|
333
338
|
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
339
|
+
if (process.env.NODE_RED_ETW_STEP_LOGGING == 'true' || process.env.NODERED_ETW_STEP_LOGGING == 'true') {
|
|
340
|
+
node._trace = `'${sourceNode.name || sourceNode.type}'->'${destinationNode.name || destinationNode.type}'`;
|
|
341
|
+
node.log(`postDeliver: ${node._trace}`);
|
|
342
|
+
}
|
|
337
343
|
}
|
|
344
|
+
} catch (error) {
|
|
345
|
+
node.error(`Error in onPostDeliver: ${error?.message}`, { error: error });
|
|
338
346
|
}
|
|
339
347
|
};
|
|
340
|
-
RED.hooks.add(
|
|
348
|
+
RED.hooks.add(`postDeliver.etw-input-${node.id}`, onPostDeliver);
|
|
341
349
|
|
|
342
350
|
node.setSubscribedStatus = () => {
|
|
343
351
|
this._subscribed = true;
|
|
@@ -632,12 +640,12 @@ module.exports = function (RED) {
|
|
|
632
640
|
|
|
633
641
|
node.on('close', () => {
|
|
634
642
|
try {
|
|
635
|
-
RED.hooks.remove('preDeliver', onPreDeliver);
|
|
636
|
-
RED.hooks.remove('postDeliver', onPostDeliver);
|
|
637
643
|
externalTaskWorker.stop();
|
|
644
|
+
RED.hooks.remove(`preDeliver.etw-input-${node.id}`);
|
|
645
|
+
RED.hooks.remove(`postDeliver.etw-input-${node.id}`);
|
|
638
646
|
node.log('External Task Worker closed.');
|
|
639
|
-
} catch {
|
|
640
|
-
node.error(
|
|
647
|
+
} catch (error) {
|
|
648
|
+
node.error(`Client close failed: ${JSON.stringify(error)}`);
|
|
641
649
|
}
|
|
642
650
|
});
|
|
643
651
|
})
|