mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2026-09-26 19:51:42 +02:00
fix(core): Clean run data for dirty nodes properly, including their children (#13821)
This commit is contained in:
@@ -4,28 +4,30 @@ import type { DirectedGraph } from './directed-graph';
|
||||
|
||||
/**
|
||||
* Returns new run data that does not contain data for any node that is a child
|
||||
* of any start node.
|
||||
* of any of the passed nodes. This is useful for cleaning run data after start
|
||||
* nodes or dirty nodes.
|
||||
*
|
||||
* This does not mutate the `runData` being passed in.
|
||||
*/
|
||||
export function cleanRunData(
|
||||
runData: IRunData,
|
||||
graph: DirectedGraph,
|
||||
startNodes: Set<INode>,
|
||||
nodesToClean: Set<INode>,
|
||||
): IRunData {
|
||||
const newRunData: IRunData = { ...runData };
|
||||
|
||||
for (const startNode of startNodes) {
|
||||
delete newRunData[startNode.name];
|
||||
for (const nodeToClean of nodesToClean) {
|
||||
delete newRunData[nodeToClean.name];
|
||||
|
||||
const children = graph.getChildren(startNode);
|
||||
for (const node of [startNode, ...children]) {
|
||||
const children = graph.getChildren(nodeToClean);
|
||||
for (const node of [nodeToClean, ...children]) {
|
||||
delete newRunData[node.name];
|
||||
|
||||
// Delete runData for subNodes
|
||||
const subNodeConnections = graph.getParentConnections(node);
|
||||
for (const subNodeConnection of subNodeConnections) {
|
||||
// Sub nodes never use the Main connection type, so this filters out
|
||||
// the connection that goes upstream of the startNode.
|
||||
// the connection that goes upstream of the node to clean.
|
||||
if (subNodeConnection.type === NodeConnectionType.Main) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user