mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
fix(core): Ensure getNodeOutputs always returns an array (#19069)
This commit is contained in:
@@ -1047,12 +1047,15 @@ export function getNodeOutputs(
|
|||||||
} else {
|
} else {
|
||||||
// Calculate the outputs dynamically
|
// Calculate the outputs dynamically
|
||||||
try {
|
try {
|
||||||
outputs = (workflow.expression.getSimpleParameterValue(
|
const result = workflow.expression.getSimpleParameterValue(
|
||||||
node,
|
node,
|
||||||
nodeTypeData.outputs,
|
nodeTypeData.outputs,
|
||||||
'internal',
|
'internal',
|
||||||
{},
|
{},
|
||||||
) || []) as NodeConnectionType[];
|
);
|
||||||
|
outputs = Array.isArray(result)
|
||||||
|
? (result as Array<NodeConnectionType | INodeOutputConfiguration>)
|
||||||
|
: [];
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.warn('Could not calculate outputs dynamically for node: ', node.name);
|
console.warn('Could not calculate outputs dynamically for node: ', node.name);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -697,15 +697,10 @@ export class Workflow {
|
|||||||
const outputs = NodeHelpers.getNodeOutputs(this, node, nodeType.description);
|
const outputs = NodeHelpers.getNodeOutputs(this, node, nodeType.description);
|
||||||
const nonMainConnectionTypes: NodeConnectionType[] = [];
|
const nonMainConnectionTypes: NodeConnectionType[] = [];
|
||||||
|
|
||||||
// Defensive check: NodeHelpers.getNodeOutputs should always return an array,
|
for (const output of outputs) {
|
||||||
// but in some edge cases (particularly during testing with incomplete node setup),
|
const type = typeof output === 'string' ? output : output.type;
|
||||||
// it may return undefined or null
|
if (type !== NodeConnectionTypes.Main) {
|
||||||
if (Array.isArray(outputs)) {
|
nonMainConnectionTypes.push(type);
|
||||||
for (const output of outputs) {
|
|
||||||
const type = typeof output === 'string' ? output : output.type;
|
|
||||||
if (type !== NodeConnectionTypes.Main) {
|
|
||||||
nonMainConnectionTypes.push(type);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user