diff --git a/packages/node_modules/@node-red/editor-client/src/js/nodes.js b/packages/node_modules/@node-red/editor-client/src/js/nodes.js index 865636b24..94bdbfcf7 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/nodes.js +++ b/packages/node_modules/@node-red/editor-client/src/js/nodes.js @@ -2095,16 +2095,27 @@ RED.nodes = (function() { } else if (n.type.substring(0,7) === "subflow") { var parentId = n.type.split(":")[1]; var subflow = subflow_denylist[parentId]||subflow_map[parentId]||getSubflow(parentId); - if (createNewIds || options.importMap[n.id] === "copy") { - parentId = subflow.id; - node.type = "subflow:"+parentId; - node._def = registry.getNodeType(node.type); - delete node.i; + if (!subflow){ + node._def = { + color:"#fee", + defaults: {}, + label: "unknown: "+n.type, + labelStyle: "red-ui-flow-node-label-italic", + outputs: n.outputs|| (n.wires && n.wires.length) || 0, + set: registry.getNodeSet("node-red/unknown") + } + } else { + if (createNewIds || options.importMap[n.id] === "copy") { + parentId = subflow.id; + node.type = "subflow:"+parentId; + node._def = registry.getNodeType(node.type); + delete node.i; + } + node.name = n.name; + node.outputs = subflow.out.length; + node.inputs = subflow.in.length; + node.env = n.env; } - node.name = n.name; - node.outputs = subflow.out.length; - node.inputs = subflow.in.length; - node.env = n.env; } else if (n.type === 'junction') { node._def = {defaults:{}} node._config.x = node.x diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/editor.js b/packages/node_modules/@node-red/editor-client/src/js/ui/editor.js index da7954625..188819734 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/editor.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/editor.js @@ -45,11 +45,13 @@ RED.editor = (function() { var hasChanged; if (node.type.indexOf("subflow:")===0) { subflow = RED.nodes.subflow(node.type.substring(8)); - isValid = subflow.valid; - hasChanged = subflow.changed; - if (isValid === undefined) { - isValid = validateNode(subflow); + if (subflow){ + isValid = subflow.valid; hasChanged = subflow.changed; + if (isValid === undefined) { + isValid = validateNode(subflow); + hasChanged = subflow.changed; + } } validationErrors = validateNodeProperties(node, node._def.defaults, node); node.valid = isValid && validationErrors.length === 0; diff --git a/packages/node_modules/@node-red/runtime/lib/flows/util.js b/packages/node_modules/@node-red/runtime/lib/flows/util.js index 7c98fc041..83665b589 100644 --- a/packages/node_modules/@node-red/runtime/lib/flows/util.js +++ b/packages/node_modules/@node-red/runtime/lib/flows/util.js @@ -199,7 +199,9 @@ function parseConfig(config) { if (subflowDetails) { var subflowType = subflowDetails[1] n.subflow = subflowType; - flow.subflows[subflowType].instances.push(n) + if (flow.subflows[subflowType]) { + flow.subflows[subflowType].instances.push(n) + } } if (container) { container.nodes[n.id] = n;