diff --git a/packages/node_modules/@node-red/runtime/lib/nodes/flows/Flow.js b/packages/node_modules/@node-red/runtime/lib/nodes/flows/Flow.js index 08c3998c5..20399f19d 100644 --- a/packages/node_modules/@node-red/runtime/lib/nodes/flows/Flow.js +++ b/packages/node_modules/@node-red/runtime/lib/nodes/flows/Flow.js @@ -322,19 +322,19 @@ class Flow { /** * Handle a status event from a node within this flow. - * @param {Node} node The original node that triggered the event - * @param {Object} statusMessage The status object - * @param {Node} reportingNode The node emitting the status event. - * This could be a subflow instance node when the status - * is being delegated up. - * @param {boolean} muteStatus Whether to emit the status event - * @return {[type]} [description] + * @param {Node} node The original node that triggered the event + * @param {Object} statusMessage The status object + * @param {Node} reportingNode The node emitting the status event. + * This could be a subflow instance node when the status + * is being delegated up. + * @param {boolean} muteStatusEvent Whether to emit the status event + * @return {[type]} [description] */ - handleStatus(node,statusMessage,reportingNode,muteStatus) { + handleStatus(node,statusMessage,reportingNode,muteStatusEvent) { if (!reportingNode) { reportingNode = node; } - if (!muteStatus) { + if (!muteStatusEvent) { events.emit("node-status",{ id: node.id, status:statusMessage @@ -343,26 +343,37 @@ class Flow { let handled = false; - this.statusNodes.forEach(function(targetStatusNode) { - if (targetStatusNode.scope && targetStatusNode.scope.indexOf(reportingNode.id) === -1) { - return; - } - var message = { - status: { - text: "", - source: { - id: node.id, - type: node.type, - name: node.name - } + if (this.id === 'global' && node.users) { + // This is a global config node + // Delegate status to any nodes using this config node + for (let userNode in node.users) { + if (node.users.hasOwnProperty(userNode)) { + node.users[userNode]._flow.handleStatus(node,statusMessage,node.users[userNode],true); } - }; - if (statusMessage.hasOwnProperty("text")) { - message.status.text = statusMessage.text.toString(); } - targetStatusNode.receive(message); handled = true; - }); + } else { + this.statusNodes.forEach(function(targetStatusNode) { + if (targetStatusNode.scope && targetStatusNode.scope.indexOf(reportingNode.id) === -1) { + return; + } + var message = { + status: { + text: "", + source: { + id: node.id, + type: node.type, + name: node.name + } + } + }; + if (statusMessage.hasOwnProperty("text")) { + message.status.text = statusMessage.text.toString(); + } + targetStatusNode.receive(message); + handled = true; + }); + } return handled; } @@ -392,35 +403,47 @@ class Flow { } } } - var handled = false; - this.catchNodes.forEach(function(targetCatchNode) { - if (targetCatchNode.scope && targetCatchNode.scope.indexOf(reportingNode.id) === -1) { - return; - } - var errorMessage; - if (msg) { - errorMessage = redUtil.cloneMessage(msg); - } else { - errorMessage = {}; - } - if (errorMessage.hasOwnProperty("error")) { - errorMessage._error = errorMessage.error; - } - errorMessage.error = { - message: logMessage.toString(), - source: { - id: node.id, - type: node.type, - name: node.name, - count: count + let handled = false; + + if (this.id === 'global' && node.users) { + // This is a global config node + // Delegate status to any nodes using this config node + for (let userNode in node.users) { + if (node.users.hasOwnProperty(userNode)) { + node.users[userNode]._flow.handleError(node,logMessage,msg,node.users[userNode]); } - }; - if (logMessage.hasOwnProperty('stack')) { - errorMessage.error.stack = logMessage.stack; } - targetCatchNode.receive(errorMessage); handled = true; - }); + } else { + this.catchNodes.forEach(function(targetCatchNode) { + if (targetCatchNode.scope && targetCatchNode.scope.indexOf(reportingNode.id) === -1) { + return; + } + var errorMessage; + if (msg) { + errorMessage = redUtil.cloneMessage(msg); + } else { + errorMessage = {}; + } + if (errorMessage.hasOwnProperty("error")) { + errorMessage._error = errorMessage.error; + } + errorMessage.error = { + message: logMessage.toString(), + source: { + id: node.id, + type: node.type, + name: node.name, + count: count + } + }; + if (logMessage.hasOwnProperty('stack')) { + errorMessage.error.stack = logMessage.stack; + } + targetCatchNode.receive(errorMessage); + handled = true; + }); + } return handled; }