fix(core): Clean run data for dirty nodes properly, including their children (#13821)

This commit is contained in:
Danny Martini
2025-03-11 16:53:51 +01:00
committed by GitHub
parent ca8d249700
commit b3f9cde3fd
5 changed files with 180 additions and 11 deletions
@@ -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;
}