mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 17:46:45 +00:00
fix(Merge Node): Fix possible stack overflow (#19101)
This commit is contained in:
@@ -291,7 +291,7 @@ export class MergeV2 implements INodeType {
|
||||
}
|
||||
|
||||
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||
const returnData: INodeExecutionData[] = [];
|
||||
let returnData: INodeExecutionData[] = [];
|
||||
|
||||
const mode = this.getNodeParameter('mode', 0) as string;
|
||||
|
||||
@@ -536,7 +536,7 @@ export class MergeV2 implements INodeType {
|
||||
output = [...output, ...unmatched1, ...unmatched2];
|
||||
}
|
||||
|
||||
returnData.push(...output);
|
||||
returnData = returnData.concat(output);
|
||||
}
|
||||
|
||||
if (joinMode === 'keepNonMatches') {
|
||||
@@ -565,15 +565,21 @@ export class MergeV2 implements INodeType {
|
||||
|
||||
if (joinMode === 'enrichInput1') {
|
||||
if (clashResolveOptions.resolveClash === 'addSuffix') {
|
||||
returnData.push(...mergedEntries, ...addSuffixToEntriesKeys(matches.unmatched1, '1'));
|
||||
returnData = returnData.concat(
|
||||
mergedEntries,
|
||||
addSuffixToEntriesKeys(matches.unmatched1, '1'),
|
||||
);
|
||||
} else {
|
||||
returnData.push(...mergedEntries, ...matches.unmatched1);
|
||||
returnData = returnData.concat(mergedEntries, matches.unmatched1);
|
||||
}
|
||||
} else {
|
||||
if (clashResolveOptions.resolveClash === 'addSuffix') {
|
||||
returnData.push(...mergedEntries, ...addSuffixToEntriesKeys(matches.unmatched2, '2'));
|
||||
returnData = returnData.concat(
|
||||
mergedEntries,
|
||||
addSuffixToEntriesKeys(matches.unmatched2, '2'),
|
||||
);
|
||||
} else {
|
||||
returnData.push(...mergedEntries, ...matches.unmatched2);
|
||||
returnData = returnData.concat(mergedEntries, matches.unmatched2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -262,7 +262,7 @@ export async function execute(
|
||||
this: IExecuteFunctions,
|
||||
inputsData: INodeExecutionData[][],
|
||||
): Promise<INodeExecutionData[][]> {
|
||||
const returnData: INodeExecutionData[] = [];
|
||||
let returnData: INodeExecutionData[] = [];
|
||||
const advanced = this.getNodeParameter('advanced', 0) as boolean;
|
||||
let matchFields;
|
||||
|
||||
@@ -374,7 +374,7 @@ export async function execute(
|
||||
output = [...output, ...unmatched1, ...unmatched2];
|
||||
}
|
||||
|
||||
returnData.push(...output);
|
||||
returnData = returnData.concat(output);
|
||||
}
|
||||
|
||||
if (joinMode === 'keepNonMatches') {
|
||||
@@ -403,15 +403,21 @@ export async function execute(
|
||||
|
||||
if (joinMode === 'enrichInput1') {
|
||||
if (clashResolveOptions.resolveClash === 'addSuffix') {
|
||||
returnData.push(...mergedEntries, ...addSuffixToEntriesKeys(matches.unmatched1, '1'));
|
||||
returnData = returnData.concat(
|
||||
mergedEntries,
|
||||
addSuffixToEntriesKeys(matches.unmatched1, '1'),
|
||||
);
|
||||
} else {
|
||||
returnData.push(...mergedEntries, ...matches.unmatched1);
|
||||
returnData = returnData.concat(mergedEntries, matches.unmatched1);
|
||||
}
|
||||
} else {
|
||||
if (clashResolveOptions.resolveClash === 'addSuffix') {
|
||||
returnData.push(...mergedEntries, ...addSuffixToEntriesKeys(matches.unmatched2, '2'));
|
||||
returnData = returnData.concat(
|
||||
mergedEntries,
|
||||
addSuffixToEntriesKeys(matches.unmatched2, '2'),
|
||||
);
|
||||
} else {
|
||||
returnData.push(...mergedEntries, ...matches.unmatched2);
|
||||
returnData = returnData.concat(mergedEntries, matches.unmatched2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ async function executeSelectWithMappedPairedItems(
|
||||
|
||||
for (const item of result) {
|
||||
if (Array.isArray(item)) {
|
||||
returnData.push(...item.map((entry) => rowToExecutionData(entry)));
|
||||
returnData.push.apply(returnData, item.map(rowToExecutionData));
|
||||
} else if (typeof item === 'object') {
|
||||
returnData.push(rowToExecutionData(item));
|
||||
}
|
||||
@@ -211,7 +211,7 @@ export async function execute(
|
||||
input: i,
|
||||
};
|
||||
});
|
||||
pairedItem.push(...pairedItems);
|
||||
pairedItem.push.apply(pairedItem, pairedItems);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -237,7 +237,10 @@ export async function execute(
|
||||
|
||||
for (const item of result) {
|
||||
if (Array.isArray(item)) {
|
||||
returnData.push(...item.map((json) => ({ json, pairedItem })));
|
||||
returnData.push.apply(
|
||||
returnData,
|
||||
item.map((json) => ({ json, pairedItem })),
|
||||
);
|
||||
} else if (typeof item === 'object') {
|
||||
returnData.push({ json: item, pairedItem });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user