@5minds/node-red-contrib-processcube 1.16.1-feature-91fab0-mhvqo2et → 1.16.1-feature-32d817-mhvxfpgt

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.
@@ -11,9 +11,7 @@ class ExternalTaskNodeStates {
11
11
  this.nodeStades[nodeId] = { gotSend: false, gotCompleted: false };
12
12
  }
13
13
 
14
- console.log(`[DEBUG] markSended - flowNodeInstanceId: ${this.flowNodeInstanceId}, nodeId: ${nodeId}, before: ${JSON.stringify(this.nodeStades[nodeId])}`);
15
14
  this.nodeStades[nodeId].gotSend = true;
16
- console.log(`[DEBUG] markSended - after: ${JSON.stringify(this.nodeStades[nodeId])}`);
17
15
  }
18
16
 
19
17
  markCompleted(nodeId) {
@@ -21,16 +19,13 @@ class ExternalTaskNodeStates {
21
19
  this.nodeStades[nodeId] = { gotSend: false, gotCompleted: false };
22
20
  }
23
21
 
24
- console.log(`[DEBUG] markCompleted - flowNodeInstanceId: ${this.flowNodeInstanceId}, nodeId: ${nodeId}, before: ${JSON.stringify(this.nodeStades[nodeId])}`);
25
22
  this.nodeStades[nodeId].gotCompleted = true;
26
- console.log(`[DEBUG] markCompleted - after: ${JSON.stringify(this.nodeStades[nodeId])}`);
27
23
  }
28
24
 
29
25
  checkIfCompletedWithoutSend(nodeId) {
30
26
  const nodeState = this.nodeStades[nodeId];
31
27
  const result = (nodeState && nodeState.gotCompleted && !nodeState.gotSend);
32
28
 
33
- console.log(`[DEBUG] checkIfCompletedWithoutSend - flowNodeInstanceId: ${this.flowNodeInstanceId}, nodeId: ${nodeId}, nodeState: ${JSON.stringify(nodeState)}, result: ${result}`);
34
29
  return result;
35
30
  }
36
31
  }
@@ -48,8 +43,6 @@ module.exports = function (RED) {
48
43
  const wires = fullNode?.wires;
49
44
  const hasConnectedOutputs = wires && wires.some(wireArray => wireArray && wireArray.length > 0);
50
45
 
51
- console.log(`[DEBUG] raiseExternalTaskError called for flowNodeInstanceId: ${flowNodeInstanceId}, nodeId: ${nodeId}, hasConnectedOutputs: ${hasConnectedOutputs}`);
52
-
53
46
  if (hasConnectedOutputs) {
54
47
  const inputNode = RED.nodes.getNode(etwInputNodeId);
55
48
 
@@ -64,10 +57,7 @@ module.exports = function (RED) {
64
57
  nodeType: fullNode.type
65
58
  });
66
59
 
67
- console.log(`[DEBUG] Emitting error event for flowNodeInstanceId: ${flowNodeInstanceId}, error: ${errorMessage}`);
68
60
  inputNode.eventEmitter.emit(`handle-${flowNodeInstanceId}`, error, true);
69
- } else {
70
- console.log(`[DEBUG] Cannot raise error - inputNode or eventEmitter not found for etwInputNodeId: ${etwInputNodeId}`);
71
61
  }
72
62
  }
73
63
  };
@@ -80,10 +70,7 @@ module.exports = function (RED) {
80
70
  if (sendEvent.msg?.flowNodeInstanceId) {
81
71
  let externalTaskNodeStates = globalExternalTaskStates[sendEvent.msg.flowNodeInstanceId];
82
72
 
83
- console.log(`[DEBUG] onSend - flowNodeInstanceId: ${sendEvent.msg.flowNodeInstanceId}, nodeId: ${sendEvent.source.node.id}, stateExists: ${!!externalTaskNodeStates}`);
84
-
85
73
  if (!externalTaskNodeStates) {
86
- console.log(`[DEBUG] onSend - Creating NEW ExternalTaskNodeStates for flowNodeInstanceId: ${sendEvent.msg.flowNodeInstanceId}`);
87
74
  externalTaskNodeStates = new ExternalTaskNodeStates(sendEvent.msg.flowNodeInstanceId);
88
75
  globalExternalTaskStates[sendEvent.msg.flowNodeInstanceId] = externalTaskNodeStates;
89
76
  }
@@ -91,7 +78,6 @@ module.exports = function (RED) {
91
78
  externalTaskNodeStates.markSended(sendEvent.source.node.id)
92
79
 
93
80
  if (externalTaskNodeStates.checkIfCompletedWithoutSend(sendEvent.source.node.id)) {
94
- console.log(`[DEBUG] onSend - Node completed without send detected! Raising error for nodeId: ${sendEvent.source.node.id}`);
95
81
  raiseExternalTaskError(sendEvent.msg.flowNodeInstanceId, sendEvent.msg.etw_input_node_id, sendEvent.source.node.id);
96
82
  }
97
83
  }
@@ -104,10 +90,7 @@ module.exports = function (RED) {
104
90
  if (completeEvent.msg?.flowNodeInstanceId) {
105
91
  let externalTaskNodeStates = globalExternalTaskStates[completeEvent.msg.flowNodeInstanceId];
106
92
 
107
- console.log(`[DEBUG] onComplete - flowNodeInstanceId: ${completeEvent.msg.flowNodeInstanceId}, nodeId: ${completeEvent.node.id}, stateExists: ${!!externalTaskNodeStates}`);
108
-
109
93
  if (!externalTaskNodeStates) {
110
- console.log(`[DEBUG] onComplete - Creating NEW ExternalTaskNodeStates for flowNodeInstanceId: ${completeEvent.msg.flowNodeInstanceId}`);
111
94
  externalTaskNodeStates = new ExternalTaskNodeStates(completeEvent.msg.flowNodeInstanceId);
112
95
  globalExternalTaskStates[completeEvent.msg.flowNodeInstanceId] = externalTaskNodeStates;
113
96
  }
@@ -115,7 +98,6 @@ module.exports = function (RED) {
115
98
  externalTaskNodeStates.markCompleted(completeEvent.node.id);
116
99
 
117
100
  if (externalTaskNodeStates.checkIfCompletedWithoutSend(completeEvent.node.id)) {
118
- console.log(`[DEBUG] onComplete - Node completed without send detected! Raising error for nodeId: ${completeEvent.node.id}`);
119
101
  raiseExternalTaskError(completeEvent.msg.flowNodeInstanceId, completeEvent.msg.etw_input_node_id, completeEvent.node.id);
120
102
  }
121
103
  }
@@ -284,60 +266,68 @@ module.exports = function (RED) {
284
266
  };
285
267
 
286
268
  const onPreDeliver = (sendEvent) => {
287
- if (node.isHandling() && node.ownMessage(sendEvent.msg)) {
288
-
289
- const sourceNode = sendEvent?.source?.node;
290
- const destinationNode = sendEvent?.destination?.node;
269
+ try {
270
+ if (node.isHandling() && node.ownMessage(sendEvent.msg)) {
291
271
 
292
- node._step = `${destinationNode.name || destinationNode.type}`;
272
+ const sourceNode = sendEvent?.source?.node;
273
+ const destinationNode = sendEvent?.destination?.node;
293
274
 
294
- node.showStatus();
275
+ node._step = `${destinationNode.name || destinationNode.type}`;
295
276
 
296
- const debugMsg = {
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
- };
277
+ node.showStatus();
278
+
279
+ const debugMsg = {
280
+ event: 'enter',
281
+ sourceName: sourceNode.name,
282
+ sourceType: sourceNode.type,
283
+ destinationNodeName: destinationNode.name,
284
+ destinationNodeType: destinationNode.type,
285
+ timestamp: new Date().toISOString(),
286
+ };
304
287
 
305
- node.traceExecution(debugMsg);
288
+ node.traceExecution(debugMsg);
306
289
 
307
- if (process.env.NODE_RED_ETW_STEP_LOGGING == 'true' || process.env.NODERED_ETW_STEP_LOGGING == 'true') {
308
- node._trace = `'${sourceNode.name || sourceNode.type}'->'${destinationNode.name || destinationNode.type}'`;
309
- node.log(`preDeliver: ${node._trace}`);
290
+ if (process.env.NODE_RED_ETW_STEP_LOGGING == 'true' || process.env.NODERED_ETW_STEP_LOGGING == 'true') {
291
+ node._trace = `'${sourceNode.name || sourceNode.type}'->'${destinationNode.name || destinationNode.type}'`;
292
+ node.log(`preDeliver: ${node._trace}`);
293
+ }
310
294
  }
295
+ } catch (error) {
296
+ node.error(`Error in onPreDeliver: ${error?.message}`, { error: error });
311
297
  }
312
298
  };
313
- RED.hooks.add('preDeliver', onPreDeliver);
299
+ RED.hooks.add(`preDeliver.etw-input-${node.id}`, onPreDeliver);
314
300
 
315
301
  const onPostDeliver = (sendEvent) => {
316
- if (node.isHandling() && node.ownMessage(sendEvent.msg)) {
317
- const sourceNode = sendEvent?.source?.node;
318
- const destinationNode = sendEvent?.destination?.node;
319
-
320
- node.decrMsgOnNode(sourceNode, sendEvent.msg);
321
- node.incMsgOnNode(destinationNode, sendEvent.msg);
322
-
323
- const debugMsg = {
324
- event: 'exit',
325
- sourceName: sourceNode.name,
326
- sourceType: sourceNode.type,
327
- destinationNodeName: destinationNode.name,
328
- destinationNodeType: destinationNode.type,
329
- timestamp: new Date().toISOString(),
330
- };
302
+ try {
303
+ if (node.isHandling() && node.ownMessage(sendEvent.msg)) {
304
+ const sourceNode = sendEvent?.source?.node;
305
+ const destinationNode = sendEvent?.destination?.node;
306
+
307
+ node.decrMsgOnNode(sourceNode, sendEvent.msg);
308
+ node.incMsgOnNode(destinationNode, sendEvent.msg);
309
+
310
+ const debugMsg = {
311
+ event: 'exit',
312
+ sourceName: sourceNode.name,
313
+ sourceType: sourceNode.type,
314
+ destinationNodeName: destinationNode.name,
315
+ destinationNodeType: destinationNode.type,
316
+ timestamp: new Date().toISOString(),
317
+ };
331
318
 
332
- node.traceExecution(debugMsg);
319
+ node.traceExecution(debugMsg);
333
320
 
334
- if (process.env.NODE_RED_ETW_STEP_LOGGING == 'true' || process.env.NODERED_ETW_STEP_LOGGING == 'true') {
335
- node._trace = `'${sourceNode.name || sourceNode.type}'->'${destinationNode.name || destinationNode.type}'`;
336
- node.log(`postDeliver: ${node._trace}`);
321
+ if (process.env.NODE_RED_ETW_STEP_LOGGING == 'true' || process.env.NODERED_ETW_STEP_LOGGING == 'true') {
322
+ node._trace = `'${sourceNode.name || sourceNode.type}'->'${destinationNode.name || destinationNode.type}'`;
323
+ node.log(`postDeliver: ${node._trace}`);
324
+ }
337
325
  }
326
+ } catch (error) {
327
+ node.error(`Error in onPostDeliver: ${error?.message}`, { error: error });
338
328
  }
339
329
  };
340
- RED.hooks.add('postDeliver', onPostDeliver);
330
+ RED.hooks.add(`postDeliver.etw-input-${node.id}`, onPostDeliver);
341
331
 
342
332
  node.setSubscribedStatus = () => {
343
333
  this._subscribed = true;
@@ -469,8 +459,6 @@ module.exports = function (RED) {
469
459
  }
470
460
  const etwCallback = async (payload, externalTask) => {
471
461
 
472
- console.log(`[DEBUG] etwCallback - NEW External Task received! flowNodeInstanceId: ${externalTask.flowNodeInstanceId}, processInstanceId: ${externalTask.processInstanceId}`);
473
- console.log(`[DEBUG] etwCallback - Creating NEW ExternalTaskNodeStates for flowNodeInstanceId: ${externalTask.flowNodeInstanceId}`);
474
462
  globalExternalTaskStates[externalTask.flowNodeInstanceId] = new ExternalTaskNodeStates(externalTask.flowNodeInstanceId);
475
463
 
476
464
  const saveHandleCallback = (data, callback, msg) => {
@@ -480,7 +468,6 @@ module.exports = function (RED) {
480
468
 
481
469
  // Remove ExternalTaskState from global dictionary
482
470
  if (globalExternalTaskStates[externalTask.flowNodeInstanceId]) {
483
- console.log(`[DEBUG] saveHandleCallback SUCCESS - Deleting ExternalTaskNodeStates for flowNodeInstanceId: ${externalTask.flowNodeInstanceId}`);
484
471
  delete globalExternalTaskStates[externalTask.flowNodeInstanceId];
485
472
  }
486
473
 
@@ -488,7 +475,6 @@ module.exports = function (RED) {
488
475
  } catch (error) {
489
476
  // Remove ExternalTaskState from global dictionary on error as well
490
477
  if (globalExternalTaskStates[externalTask.flowNodeInstanceId]) {
491
- console.log(`[DEBUG] saveHandleCallback ERROR - Deleting ExternalTaskNodeStates for flowNodeInstanceId: ${externalTask.flowNodeInstanceId}, error: ${error?.message}`);
492
478
  delete globalExternalTaskStates[externalTask.flowNodeInstanceId];
493
479
  }
494
480
 
@@ -516,7 +502,6 @@ module.exports = function (RED) {
516
502
  };
517
503
 
518
504
  const handleErrorTask = (error) => {
519
- console.log(`[DEBUG] handleErrorTask - flowNodeInstanceId: ${externalTask.flowNodeInstanceId}, errorCode: ${error?.errorCode}, errorMessage: ${error?.message}`);
520
505
  node.log(
521
506
  `handle error event for *external task flowNodeInstanceId* '${externalTask.flowNodeInstanceId}' and *processInstanceId* '${externalTask.processInstanceId}' on *msg._msgid* '${error.errorDetails?._msgid}'.`
522
507
  );
@@ -529,8 +514,6 @@ module.exports = function (RED) {
529
514
  };
530
515
 
531
516
  node.eventEmitter.once(`handle-${externalTask.flowNodeInstanceId}`, (msg, isError = false) => {
532
- console.log(`[DEBUG] eventEmitter handle event - flowNodeInstanceId: ${externalTask.flowNodeInstanceId}, isError: ${isError}, msgId: ${msg._msgid}`);
533
-
534
517
  try {
535
518
  msg.etw_finished_at = new Date().toISOString();
536
519
 
@@ -547,10 +530,8 @@ module.exports = function (RED) {
547
530
 
548
531
 
549
532
  if (isError) {
550
- console.log(`[DEBUG] Routing to handleErrorTask`);
551
533
  handleErrorTask(msg);
552
534
  } else {
553
- console.log(`[DEBUG] Routing to handleFinishTask`);
554
535
  handleFinishTask(msg);
555
536
  }
556
537
  });
@@ -572,7 +553,6 @@ module.exports = function (RED) {
572
553
  );
573
554
 
574
555
  node.send(msg);
575
- console.log(`[DEBUG] etwCallback - Sent message for flowNodeInstanceId: ${externalTask.flowNodeInstanceId}, msgId: ${msg._msgid}`);
576
556
  });
577
557
  };
578
558
 
@@ -632,12 +612,12 @@ module.exports = function (RED) {
632
612
 
633
613
  node.on('close', () => {
634
614
  try {
635
- RED.hooks.remove('preDeliver', onPreDeliver);
636
- RED.hooks.remove('postDeliver', onPostDeliver);
637
615
  externalTaskWorker.stop();
616
+ RED.hooks.remove(`preDeliver.etw-input-${node.id}`);
617
+ RED.hooks.remove(`postDeliver.etw-input-${node.id}`);
638
618
  node.log('External Task Worker closed.');
639
- } catch {
640
- node.error('Client close failed', {});
619
+ } catch (error) {
620
+ node.error(`Client close failed: ${JSON.stringify(error)}`);
641
621
  }
642
622
  });
643
623
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@5minds/node-red-contrib-processcube",
3
- "version": "1.16.1-feature-91fab0-mhvqo2et",
3
+ "version": "1.16.1-feature-32d817-mhvxfpgt",
4
4
  "license": "MIT",
5
5
  "description": "Node-RED nodes for ProcessCube",
6
6
  "scripts": {