From 1eb5e119346e9073f993e86bbaafda56cf62a1bb Mon Sep 17 00:00:00 2001 From: Robin Lenz Date: Wed, 12 Nov 2025 09:28:47 +0100 Subject: [PATCH 1/3] trace message --- .processcube/nodered/.flows.json.backup | 61 ++++++++-- .processcube/nodered/flows.json | 61 ++++++++-- externaltask-input.js | 146 +++++++++++++++++++++++- processes/External-Task-Hang.bpmn | 58 ++++++++++ 4 files changed, 301 insertions(+), 25 deletions(-) create mode 100644 processes/External-Task-Hang.bpmn diff --git a/.processcube/nodered/.flows.json.backup b/.processcube/nodered/.flows.json.backup index d95ae4a..03b171d 100644 --- a/.processcube/nodered/.flows.json.backup +++ b/.processcube/nodered/.flows.json.backup @@ -1777,7 +1777,7 @@ "wires": [] }, { - "id": "f80c13daa49ee8dd", + "id": "aa0790a54e613a4f", "type": "externaltask-input", "z": "a23d2e782beb66f4", "name": "", @@ -1788,43 +1788,80 @@ "workerConfig": "{}", "workerConfigType": "json", "traces": [], - "x": 100, - "y": 1680, + "x": 140, + "y": 1660, "wires": [ [ - "10aaf6e4aa5eacbe" + "7a2b98f81e1423ee", + "a55984c3ea0a1752" ] ] }, { - "id": "10aaf6e4aa5eacbe", + "id": "c690a8a876c4ac00", "type": "function", "z": "a23d2e782beb66f4", "name": "function 4", - "func": "\nreturn msg;", + "func": "return msg;", "outputs": 1, "timeout": 0, "noerr": 0, "initialize": "", "finalize": "", "libs": [], - "x": 360, - "y": 1680, + "x": 620, + "y": 1660, "wires": [ [ - "f943a85ad6ddd7df" + "f05bde567a6fe14c" ] ] }, { - "id": "f943a85ad6ddd7df", + "id": "f05bde567a6fe14c", "type": "externaltask-output", "z": "a23d2e782beb66f4", "name": "", - "x": 580, - "y": 1680, + "x": 810, + "y": 1660, "wires": [] }, + { + "id": "7a2b98f81e1423ee", + "type": "debug", + "z": "a23d2e782beb66f4", + "name": "debug 12", + "active": true, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "false", + "statusVal": "", + "statusType": "auto", + "x": 380, + "y": 1760, + "wires": [] + }, + { + "id": "a55984c3ea0a1752", + "type": "function", + "z": "a23d2e782beb66f4", + "name": "function 5", + "func": "\nreturn msg;", + "outputs": 1, + "timeout": 0, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 380, + "y": 1660, + "wires": [ + [ + "c690a8a876c4ac00" + ] + ] + }, { "id": "82533b02fb9a9f04", "type": "comment", diff --git a/.processcube/nodered/flows.json b/.processcube/nodered/flows.json index b00330e..041745e 100644 --- a/.processcube/nodered/flows.json +++ b/.processcube/nodered/flows.json @@ -1777,7 +1777,7 @@ "wires": [] }, { - "id": "f80c13daa49ee8dd", + "id": "aa0790a54e613a4f", "type": "externaltask-input", "z": "a23d2e782beb66f4", "name": "", @@ -1788,43 +1788,80 @@ "workerConfig": "{}", "workerConfigType": "json", "traces": [], - "x": 100, - "y": 1680, + "x": 140, + "y": 1660, "wires": [ [ - "10aaf6e4aa5eacbe" + "7a2b98f81e1423ee", + "a55984c3ea0a1752" ] ] }, { - "id": "10aaf6e4aa5eacbe", + "id": "c690a8a876c4ac00", "type": "function", "z": "a23d2e782beb66f4", "name": "function 4", - "func": "\nreturn msg;", + "func": "//return msg;", "outputs": 1, "timeout": 0, "noerr": 0, "initialize": "", "finalize": "", "libs": [], - "x": 340, - "y": 1680, + "x": 620, + "y": 1660, "wires": [ [ - "f943a85ad6ddd7df" + "f05bde567a6fe14c" ] ] }, { - "id": "f943a85ad6ddd7df", + "id": "f05bde567a6fe14c", "type": "externaltask-output", "z": "a23d2e782beb66f4", "name": "", - "x": 580, - "y": 1680, + "x": 810, + "y": 1660, "wires": [] }, + { + "id": "7a2b98f81e1423ee", + "type": "debug", + "z": "a23d2e782beb66f4", + "name": "debug 12", + "active": true, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "false", + "statusVal": "", + "statusType": "auto", + "x": 380, + "y": 1760, + "wires": [] + }, + { + "id": "a55984c3ea0a1752", + "type": "function", + "z": "a23d2e782beb66f4", + "name": "function 5", + "func": "\nreturn msg;", + "outputs": 1, + "timeout": 0, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 380, + "y": 1660, + "wires": [ + [ + "c690a8a876c4ac00" + ] + ] + }, { "id": "82533b02fb9a9f04", "type": "comment", diff --git a/externaltask-input.js b/externaltask-input.js index 075cc0d..9f12651 100644 --- a/externaltask-input.js +++ b/externaltask-input.js @@ -1,9 +1,128 @@ const EventEmitter = require('node:events'); +class ExternalTaskNodeStates { + constructor(flowNodeInstanceId) { + this.flowNodeInstanceId = flowNodeInstanceId; + this.nodeStades = {}; // Track send calls per nodeId + } + + markSended(nodeId) { + if (!this.nodeStades[nodeId]) { + this.nodeStades[nodeId] = { gotSend: false, gotCompleted: false }; + } + + console.log(`[DEBUG] markSended - flowNodeInstanceId: ${this.flowNodeInstanceId}, nodeId: ${nodeId}, before: ${JSON.stringify(this.nodeStades[nodeId])}`); + this.nodeStades[nodeId].gotSend = true; + console.log(`[DEBUG] markSended - after: ${JSON.stringify(this.nodeStades[nodeId])}`); + } + + markCompleted(nodeId) { + if (!this.nodeStades[nodeId]) { + this.nodeStades[nodeId] = { gotSend: false, gotCompleted: false }; + } + + console.log(`[DEBUG] markCompleted - flowNodeInstanceId: ${this.flowNodeInstanceId}, nodeId: ${nodeId}, before: ${JSON.stringify(this.nodeStades[nodeId])}`); + this.nodeStades[nodeId].gotCompleted = true; + console.log(`[DEBUG] markCompleted - after: ${JSON.stringify(this.nodeStades[nodeId])}`); + } + + checkIfCompletedWithoutSend(nodeId) { + const nodeState = this.nodeStades[nodeId]; + const result = (nodeState && nodeState.gotCompleted && !nodeState.gotSend); + + console.log(`[DEBUG] checkIfCompletedWithoutSend - flowNodeInstanceId: ${this.flowNodeInstanceId}, nodeId: ${nodeId}, nodeState: ${JSON.stringify(nodeState)}, result: ${result}`); + return result; + } +} + module.exports = function (RED) { const os = require('os'); + // Global dictionary for tracking external tasks by flowNodeInstanceId + const globalExternalTaskStates = {}; + + const raiseExternalTaskError = (flowNodeInstanceId, etwInputNodeId, nodeId) => { + const fullNode = RED.nodes.getNode(nodeId); + + const wires = fullNode?.wires; + const hasConnectedOutputs = wires && wires.some(wireArray => wireArray && wireArray.length > 0); + + console.log(`[DEBUG] raiseExternalTaskError called for flowNodeInstanceId: ${flowNodeInstanceId}, nodeId: ${nodeId}, hasConnectedOutputs: ${hasConnectedOutputs}`); + + if (hasConnectedOutputs) { + const inputNode = RED.nodes.getNode(etwInputNodeId); + + if (inputNode && inputNode.eventEmitter) { + const errorMessage = `Node ${nodeId} (${fullNode.name || fullNode.type}) completed without sending output`; + const error = new Error(errorMessage); + error.errorCode = 'NODE_NO_OUTPUT'; + error.errorDetails = RED.util.encodeObject({ + flowNodeInstanceId: flowNodeInstanceId, + nodeId: nodeId, + nodeName: fullNode.name, + nodeType: fullNode.type + }); + + console.log(`[DEBUG] Emitting error event for flowNodeInstanceId: ${flowNodeInstanceId}, error: ${errorMessage}`); + inputNode.eventEmitter.emit(`handle-${flowNodeInstanceId}`, error, true); + } else { + console.log(`[DEBUG] Cannot raise error - inputNode or eventEmitter not found for etwInputNodeId: ${etwInputNodeId}`); + } + } + }; + + // Example synchronous onSend hook + RED.hooks.add("onSend", (sendEvents) => { + for (const sendEvent of sendEvents) { + + // Call send method on ExternalTaskState if this message has a flowNodeInstanceId + if (sendEvent.msg?.flowNodeInstanceId) { + let externalTaskNodeStates = globalExternalTaskStates[sendEvent.msg.flowNodeInstanceId]; + + console.log(`[DEBUG] onSend - flowNodeInstanceId: ${sendEvent.msg.flowNodeInstanceId}, nodeId: ${sendEvent.source.node.id}, stateExists: ${!!externalTaskNodeStates}`); + + if (!externalTaskNodeStates) { + console.log(`[DEBUG] onSend - Creating NEW ExternalTaskNodeStates for flowNodeInstanceId: ${sendEvent.msg.flowNodeInstanceId}`); + externalTaskNodeStates = new ExternalTaskNodeStates(sendEvent.msg.flowNodeInstanceId); + globalExternalTaskStates[sendEvent.msg.flowNodeInstanceId] = externalTaskNodeStates; + } + + externalTaskNodeStates.markSended(sendEvent.source.node.id) + + if (externalTaskNodeStates.checkIfCompletedWithoutSend(sendEvent.source.node.id)) { + console.log(`[DEBUG] onSend - Node completed without send detected! Raising error for nodeId: ${sendEvent.source.node.id}`); + raiseExternalTaskError(sendEvent.msg.flowNodeInstanceId, sendEvent.msg.etw_input_node_id, sendEvent.source.node.id); + } + } + } + }); + + const onCompleted = (completeEvent) => { + + // Check if this is an external task message + if (completeEvent.msg?.flowNodeInstanceId) { + let externalTaskNodeStates = globalExternalTaskStates[completeEvent.msg.flowNodeInstanceId]; + + console.log(`[DEBUG] onComplete - flowNodeInstanceId: ${completeEvent.msg.flowNodeInstanceId}, nodeId: ${completeEvent.node.id}, stateExists: ${!!externalTaskNodeStates}`); + + if (!externalTaskNodeStates) { + console.log(`[DEBUG] onComplete - Creating NEW ExternalTaskNodeStates for flowNodeInstanceId: ${completeEvent.msg.flowNodeInstanceId}`); + externalTaskNodeStates = new ExternalTaskNodeStates(completeEvent.msg.flowNodeInstanceId); + globalExternalTaskStates[completeEvent.msg.flowNodeInstanceId] = externalTaskNodeStates; + } + + externalTaskNodeStates.markCompleted(completeEvent.node.id); + + if (externalTaskNodeStates.checkIfCompletedWithoutSend(completeEvent.node.id)) { + console.log(`[DEBUG] onComplete - Node completed without send detected! Raising error for nodeId: ${completeEvent.node.id}`); + raiseExternalTaskError(completeEvent.msg.flowNodeInstanceId, completeEvent.msg.etw_input_node_id, completeEvent.node.id); + } + } + } + + RED.hooks.add("onComplete", onCompleted); + function ExternalTaskInput(config) { RED.nodes.createNode(this, config); var node = this; @@ -357,15 +476,34 @@ module.exports = function (RED) { return; } const etwCallback = async (payload, externalTask) => { + + console.log(`[DEBUG] etwCallback - NEW External Task received! flowNodeInstanceId: ${externalTask.flowNodeInstanceId}, processInstanceId: ${externalTask.processInstanceId}`); + console.log(`[DEBUG] etwCallback - Creating NEW ExternalTaskNodeStates for flowNodeInstanceId: ${externalTask.flowNodeInstanceId}`); + globalExternalTaskStates[externalTask.flowNodeInstanceId] = new ExternalTaskNodeStates(externalTask.flowNodeInstanceId); + const saveHandleCallback = (data, callback, msg) => { try { callback(data); node.log(`send to engine *external task flowNodeInstanceId* '${externalTask.flowNodeInstanceId}', topic '${node.topic}' and *processInstanceId* ${externalTask.processInstanceId}`); + + // Remove ExternalTaskState from global dictionary + if (globalExternalTaskStates[externalTask.flowNodeInstanceId]) { + console.log(`[DEBUG] saveHandleCallback SUCCESS - Deleting ExternalTaskNodeStates for flowNodeInstanceId: ${externalTask.flowNodeInstanceId}`); + delete globalExternalTaskStates[externalTask.flowNodeInstanceId]; + } + node.setFinishHandlingTaskStatus(externalTask); } catch (error) { + // Remove ExternalTaskState from global dictionary on error as well + if (globalExternalTaskStates[externalTask.flowNodeInstanceId]) { + console.log(`[DEBUG] saveHandleCallback ERROR - Deleting ExternalTaskNodeStates for flowNodeInstanceId: ${externalTask.flowNodeInstanceId}, error: ${error?.message}`); + delete globalExternalTaskStates[externalTask.flowNodeInstanceId]; + } + node.setErrorFinishHandlingTaskStatus(externalTask, error); msg.error = error; node.error(`failed send to engine *external task flowNodeInstanceId* '${externalTask.flowNodeInstanceId}', topic '${node.topic}' and *processInstanceId* ${externalTask.processInstanceId}: ${error?.message}`, msg); + callback(error); } }; @@ -386,6 +524,7 @@ module.exports = function (RED) { }; const handleErrorTask = (error) => { + console.log(`[DEBUG] handleErrorTask - flowNodeInstanceId: ${externalTask.flowNodeInstanceId}, errorCode: ${error?.errorCode}, errorMessage: ${error?.message}`); node.log( `handle error event for *external task flowNodeInstanceId* '${externalTask.flowNodeInstanceId}' and *processInstanceId* '${externalTask.processInstanceId}' on *msg._msgid* '${error.errorDetails?._msgid}'.` ); @@ -398,6 +537,8 @@ module.exports = function (RED) { }; node.eventEmitter.once(`handle-${externalTask.flowNodeInstanceId}`, (msg, isError = false) => { + console.log(`[DEBUG] eventEmitter handle event - flowNodeInstanceId: ${externalTask.flowNodeInstanceId}, isError: ${isError}, msgId: ${msg._msgid}`); + try { msg.etw_finished_at = new Date().toISOString(); @@ -405,7 +546,7 @@ module.exports = function (RED) { msg.etw_duration = new Date(msg.etw_finished_at) - new Date(msg.etw_started_at); } } catch (error) { - node.error(`failed to calculate duration: ${error?.message}`, msg); + node.error(`failed to calculate duration: ${error?.message}`, msg); } node.log( @@ -414,8 +555,10 @@ module.exports = function (RED) { if (isError) { + console.log(`[DEBUG] Routing to handleErrorTask`); handleErrorTask(msg); } else { + console.log(`[DEBUG] Routing to handleFinishTask`); handleFinishTask(msg); } }); @@ -437,6 +580,7 @@ module.exports = function (RED) { ); node.send(msg); + console.log(`[DEBUG] etwCallback - Sent message for flowNodeInstanceId: ${externalTask.flowNodeInstanceId}, msgId: ${msg._msgid}`); }); }; diff --git a/processes/External-Task-Hang.bpmn b/processes/External-Task-Hang.bpmn new file mode 100644 index 0000000..a83dcb2 --- /dev/null +++ b/processes/External-Task-Hang.bpmn @@ -0,0 +1,58 @@ + + + + + + + + + StartEvent_1 + Event_0i7y8nc + Activity_1yuj5dj + + + + Flow_0sy9qtj + + + + Flow_0con52z + + + + Flow_0sy9qtj + Flow_0con52z + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From b8d70be37bec0dee2ce9476aa3464179516293b5 Mon Sep 17 00:00:00 2001 From: Robin Lenz Date: Wed, 12 Nov 2025 12:32:30 +0100 Subject: [PATCH 2/3] add test flow --- .processcube/nodered/.flows.json.backup | 77 +++++++++++++++++++------ .processcube/nodered/flows.json | 77 +++++++++++++++++++------ 2 files changed, 120 insertions(+), 34 deletions(-) diff --git a/.processcube/nodered/.flows.json.backup b/.processcube/nodered/.flows.json.backup index 03b171d..c3bae40 100644 --- a/.processcube/nodered/.flows.json.backup +++ b/.processcube/nodered/.flows.json.backup @@ -826,6 +826,32 @@ "w": 932, "h": 142 }, + { + "id": "e910eea0845632e3", + "type": "group", + "z": "a23d2e782beb66f4", + "style": { + "stroke": "#999999", + "stroke-opacity": "1", + "fill": "none", + "fill-opacity": "1", + "label": true, + "label-position": "nw", + "color": "#a4a4a4" + }, + "nodes": [ + "aa0790a54e613a4f", + "a55984c3ea0a1752", + "c690a8a876c4ac00", + "f05bde567a6fe14c", + "2c4d864dde746bee", + "f3f34fd07e42d94e" + ], + "x": 34, + "y": 1619, + "w": 892, + "h": 162 + }, { "id": "42e6796dddd9d4db", "type": "processcube-engine-config", @@ -1780,6 +1806,7 @@ "id": "aa0790a54e613a4f", "type": "externaltask-input", "z": "a23d2e782beb66f4", + "g": "e910eea0845632e3", "name": "", "workername": "", "engine": "42e6796dddd9d4db", @@ -1792,7 +1819,6 @@ "y": 1660, "wires": [ [ - "7a2b98f81e1423ee", "a55984c3ea0a1752" ] ] @@ -1801,6 +1827,7 @@ "id": "c690a8a876c4ac00", "type": "function", "z": "a23d2e782beb66f4", + "g": "e910eea0845632e3", "name": "function 4", "func": "return msg;", "outputs": 1, @@ -1821,31 +1848,17 @@ "id": "f05bde567a6fe14c", "type": "externaltask-output", "z": "a23d2e782beb66f4", + "g": "e910eea0845632e3", "name": "", "x": 810, "y": 1660, "wires": [] }, - { - "id": "7a2b98f81e1423ee", - "type": "debug", - "z": "a23d2e782beb66f4", - "name": "debug 12", - "active": true, - "tosidebar": true, - "console": false, - "tostatus": false, - "complete": "false", - "statusVal": "", - "statusType": "auto", - "x": 380, - "y": 1760, - "wires": [] - }, { "id": "a55984c3ea0a1752", "type": "function", "z": "a23d2e782beb66f4", + "g": "e910eea0845632e3", "name": "function 5", "func": "\nreturn msg;", "outputs": 1, @@ -1862,6 +1875,36 @@ ] ] }, + { + "id": "2c4d864dde746bee", + "type": "catch", + "z": "a23d2e782beb66f4", + "g": "e910eea0845632e3", + "name": "", + "scope": "group", + "uncaught": false, + "x": 390, + "y": 1740, + "wires": [ + [ + "f3f34fd07e42d94e" + ] + ] + }, + { + "id": "f3f34fd07e42d94e", + "type": "externaltask-error", + "z": "a23d2e782beb66f4", + "g": "e910eea0845632e3", + "name": "", + "error": "", + "message": "", + "x": 640, + "y": 1740, + "wires": [ + [] + ] + }, { "id": "82533b02fb9a9f04", "type": "comment", diff --git a/.processcube/nodered/flows.json b/.processcube/nodered/flows.json index 041745e..021bbdd 100644 --- a/.processcube/nodered/flows.json +++ b/.processcube/nodered/flows.json @@ -826,6 +826,32 @@ "w": 932, "h": 142 }, + { + "id": "e910eea0845632e3", + "type": "group", + "z": "a23d2e782beb66f4", + "style": { + "stroke": "#999999", + "stroke-opacity": "1", + "fill": "none", + "fill-opacity": "1", + "label": true, + "label-position": "nw", + "color": "#a4a4a4" + }, + "nodes": [ + "aa0790a54e613a4f", + "a55984c3ea0a1752", + "c690a8a876c4ac00", + "f05bde567a6fe14c", + "2c4d864dde746bee", + "f3f34fd07e42d94e" + ], + "x": 34, + "y": 1619, + "w": 892, + "h": 162 + }, { "id": "42e6796dddd9d4db", "type": "processcube-engine-config", @@ -1780,6 +1806,7 @@ "id": "aa0790a54e613a4f", "type": "externaltask-input", "z": "a23d2e782beb66f4", + "g": "e910eea0845632e3", "name": "", "workername": "", "engine": "42e6796dddd9d4db", @@ -1792,7 +1819,6 @@ "y": 1660, "wires": [ [ - "7a2b98f81e1423ee", "a55984c3ea0a1752" ] ] @@ -1801,6 +1827,7 @@ "id": "c690a8a876c4ac00", "type": "function", "z": "a23d2e782beb66f4", + "g": "e910eea0845632e3", "name": "function 4", "func": "//return msg;", "outputs": 1, @@ -1821,31 +1848,17 @@ "id": "f05bde567a6fe14c", "type": "externaltask-output", "z": "a23d2e782beb66f4", + "g": "e910eea0845632e3", "name": "", "x": 810, "y": 1660, "wires": [] }, - { - "id": "7a2b98f81e1423ee", - "type": "debug", - "z": "a23d2e782beb66f4", - "name": "debug 12", - "active": true, - "tosidebar": true, - "console": false, - "tostatus": false, - "complete": "false", - "statusVal": "", - "statusType": "auto", - "x": 380, - "y": 1760, - "wires": [] - }, { "id": "a55984c3ea0a1752", "type": "function", "z": "a23d2e782beb66f4", + "g": "e910eea0845632e3", "name": "function 5", "func": "\nreturn msg;", "outputs": 1, @@ -1862,6 +1875,36 @@ ] ] }, + { + "id": "2c4d864dde746bee", + "type": "catch", + "z": "a23d2e782beb66f4", + "g": "e910eea0845632e3", + "name": "", + "scope": "group", + "uncaught": false, + "x": 390, + "y": 1740, + "wires": [ + [ + "f3f34fd07e42d94e" + ] + ] + }, + { + "id": "f3f34fd07e42d94e", + "type": "externaltask-error", + "z": "a23d2e782beb66f4", + "g": "e910eea0845632e3", + "name": "", + "error": "", + "message": "", + "x": 640, + "y": 1740, + "wires": [ + [] + ] + }, { "id": "82533b02fb9a9f04", "type": "comment", From 32d81797af83bd137632d5e73ab7d8694dcc9905 Mon Sep 17 00:00:00 2001 From: Robin Lenz Date: Wed, 12 Nov 2025 12:38:18 +0100 Subject: [PATCH 3/3] remove logs --- externaltask-input.js | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/externaltask-input.js b/externaltask-input.js index 9f12651..6cbf939 100644 --- a/externaltask-input.js +++ b/externaltask-input.js @@ -11,9 +11,7 @@ class ExternalTaskNodeStates { this.nodeStades[nodeId] = { gotSend: false, gotCompleted: false }; } - console.log(`[DEBUG] markSended - flowNodeInstanceId: ${this.flowNodeInstanceId}, nodeId: ${nodeId}, before: ${JSON.stringify(this.nodeStades[nodeId])}`); this.nodeStades[nodeId].gotSend = true; - console.log(`[DEBUG] markSended - after: ${JSON.stringify(this.nodeStades[nodeId])}`); } markCompleted(nodeId) { @@ -21,16 +19,13 @@ class ExternalTaskNodeStates { this.nodeStades[nodeId] = { gotSend: false, gotCompleted: false }; } - console.log(`[DEBUG] markCompleted - flowNodeInstanceId: ${this.flowNodeInstanceId}, nodeId: ${nodeId}, before: ${JSON.stringify(this.nodeStades[nodeId])}`); this.nodeStades[nodeId].gotCompleted = true; - console.log(`[DEBUG] markCompleted - after: ${JSON.stringify(this.nodeStades[nodeId])}`); } checkIfCompletedWithoutSend(nodeId) { const nodeState = this.nodeStades[nodeId]; const result = (nodeState && nodeState.gotCompleted && !nodeState.gotSend); - console.log(`[DEBUG] checkIfCompletedWithoutSend - flowNodeInstanceId: ${this.flowNodeInstanceId}, nodeId: ${nodeId}, nodeState: ${JSON.stringify(nodeState)}, result: ${result}`); return result; } } @@ -48,8 +43,6 @@ module.exports = function (RED) { const wires = fullNode?.wires; const hasConnectedOutputs = wires && wires.some(wireArray => wireArray && wireArray.length > 0); - console.log(`[DEBUG] raiseExternalTaskError called for flowNodeInstanceId: ${flowNodeInstanceId}, nodeId: ${nodeId}, hasConnectedOutputs: ${hasConnectedOutputs}`); - if (hasConnectedOutputs) { const inputNode = RED.nodes.getNode(etwInputNodeId); @@ -64,10 +57,7 @@ module.exports = function (RED) { nodeType: fullNode.type }); - console.log(`[DEBUG] Emitting error event for flowNodeInstanceId: ${flowNodeInstanceId}, error: ${errorMessage}`); inputNode.eventEmitter.emit(`handle-${flowNodeInstanceId}`, error, true); - } else { - console.log(`[DEBUG] Cannot raise error - inputNode or eventEmitter not found for etwInputNodeId: ${etwInputNodeId}`); } } }; @@ -80,10 +70,7 @@ module.exports = function (RED) { if (sendEvent.msg?.flowNodeInstanceId) { let externalTaskNodeStates = globalExternalTaskStates[sendEvent.msg.flowNodeInstanceId]; - console.log(`[DEBUG] onSend - flowNodeInstanceId: ${sendEvent.msg.flowNodeInstanceId}, nodeId: ${sendEvent.source.node.id}, stateExists: ${!!externalTaskNodeStates}`); - if (!externalTaskNodeStates) { - console.log(`[DEBUG] onSend - Creating NEW ExternalTaskNodeStates for flowNodeInstanceId: ${sendEvent.msg.flowNodeInstanceId}`); externalTaskNodeStates = new ExternalTaskNodeStates(sendEvent.msg.flowNodeInstanceId); globalExternalTaskStates[sendEvent.msg.flowNodeInstanceId] = externalTaskNodeStates; } @@ -91,7 +78,6 @@ module.exports = function (RED) { externalTaskNodeStates.markSended(sendEvent.source.node.id) if (externalTaskNodeStates.checkIfCompletedWithoutSend(sendEvent.source.node.id)) { - console.log(`[DEBUG] onSend - Node completed without send detected! Raising error for nodeId: ${sendEvent.source.node.id}`); raiseExternalTaskError(sendEvent.msg.flowNodeInstanceId, sendEvent.msg.etw_input_node_id, sendEvent.source.node.id); } } @@ -104,10 +90,7 @@ module.exports = function (RED) { if (completeEvent.msg?.flowNodeInstanceId) { let externalTaskNodeStates = globalExternalTaskStates[completeEvent.msg.flowNodeInstanceId]; - console.log(`[DEBUG] onComplete - flowNodeInstanceId: ${completeEvent.msg.flowNodeInstanceId}, nodeId: ${completeEvent.node.id}, stateExists: ${!!externalTaskNodeStates}`); - if (!externalTaskNodeStates) { - console.log(`[DEBUG] onComplete - Creating NEW ExternalTaskNodeStates for flowNodeInstanceId: ${completeEvent.msg.flowNodeInstanceId}`); externalTaskNodeStates = new ExternalTaskNodeStates(completeEvent.msg.flowNodeInstanceId); globalExternalTaskStates[completeEvent.msg.flowNodeInstanceId] = externalTaskNodeStates; } @@ -115,7 +98,6 @@ module.exports = function (RED) { externalTaskNodeStates.markCompleted(completeEvent.node.id); if (externalTaskNodeStates.checkIfCompletedWithoutSend(completeEvent.node.id)) { - console.log(`[DEBUG] onComplete - Node completed without send detected! Raising error for nodeId: ${completeEvent.node.id}`); raiseExternalTaskError(completeEvent.msg.flowNodeInstanceId, completeEvent.msg.etw_input_node_id, completeEvent.node.id); } } @@ -477,8 +459,6 @@ module.exports = function (RED) { } const etwCallback = async (payload, externalTask) => { - console.log(`[DEBUG] etwCallback - NEW External Task received! flowNodeInstanceId: ${externalTask.flowNodeInstanceId}, processInstanceId: ${externalTask.processInstanceId}`); - console.log(`[DEBUG] etwCallback - Creating NEW ExternalTaskNodeStates for flowNodeInstanceId: ${externalTask.flowNodeInstanceId}`); globalExternalTaskStates[externalTask.flowNodeInstanceId] = new ExternalTaskNodeStates(externalTask.flowNodeInstanceId); const saveHandleCallback = (data, callback, msg) => { @@ -488,7 +468,6 @@ module.exports = function (RED) { // Remove ExternalTaskState from global dictionary if (globalExternalTaskStates[externalTask.flowNodeInstanceId]) { - console.log(`[DEBUG] saveHandleCallback SUCCESS - Deleting ExternalTaskNodeStates for flowNodeInstanceId: ${externalTask.flowNodeInstanceId}`); delete globalExternalTaskStates[externalTask.flowNodeInstanceId]; } @@ -496,7 +475,6 @@ module.exports = function (RED) { } catch (error) { // Remove ExternalTaskState from global dictionary on error as well if (globalExternalTaskStates[externalTask.flowNodeInstanceId]) { - console.log(`[DEBUG] saveHandleCallback ERROR - Deleting ExternalTaskNodeStates for flowNodeInstanceId: ${externalTask.flowNodeInstanceId}, error: ${error?.message}`); delete globalExternalTaskStates[externalTask.flowNodeInstanceId]; } @@ -524,7 +502,6 @@ module.exports = function (RED) { }; const handleErrorTask = (error) => { - console.log(`[DEBUG] handleErrorTask - flowNodeInstanceId: ${externalTask.flowNodeInstanceId}, errorCode: ${error?.errorCode}, errorMessage: ${error?.message}`); node.log( `handle error event for *external task flowNodeInstanceId* '${externalTask.flowNodeInstanceId}' and *processInstanceId* '${externalTask.processInstanceId}' on *msg._msgid* '${error.errorDetails?._msgid}'.` ); @@ -537,8 +514,6 @@ module.exports = function (RED) { }; node.eventEmitter.once(`handle-${externalTask.flowNodeInstanceId}`, (msg, isError = false) => { - console.log(`[DEBUG] eventEmitter handle event - flowNodeInstanceId: ${externalTask.flowNodeInstanceId}, isError: ${isError}, msgId: ${msg._msgid}`); - try { msg.etw_finished_at = new Date().toISOString(); @@ -555,10 +530,8 @@ module.exports = function (RED) { if (isError) { - console.log(`[DEBUG] Routing to handleErrorTask`); handleErrorTask(msg); } else { - console.log(`[DEBUG] Routing to handleFinishTask`); handleFinishTask(msg); } }); @@ -580,7 +553,6 @@ module.exports = function (RED) { ); node.send(msg); - console.log(`[DEBUG] etwCallback - Sent message for flowNodeInstanceId: ${externalTask.flowNodeInstanceId}, msgId: ${msg._msgid}`); }); };