Skip to content

Commit cbf2476

Browse files
despairbluenetroy
andauthoredMar 10, 2025
fix(core): Find correct start nodes when the first node after that has no run data has pinned data (#13784)
Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <netroy@users.noreply.github.com>
1 parent 8043a6c commit cbf2476

File tree

2 files changed

+62
-1
lines changed

2 files changed

+62
-1
lines changed
 

‎packages/core/src/execution-engine/partial-execution-utils/__tests__/find-start-nodes.test.ts

+60
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,49 @@ describe('findStartNodes', () => {
443443
expect(startNodes).toContainEqual(node2);
444444
});
445445

446+
describe('pinData', () => {
447+
// PD ►►
448+
// ┌───────┐1 ┌──────────┐0 ┌───────────┐
449+
// │trigger├────►pinnedNode├────►destination│
450+
// └───────┘ └──────────┘ └───────────┘
451+
test('does not stop recursing when the first node that has no run data has pinned data', () => {
452+
// ARRANGE
453+
const trigger = createNodeData({ name: 'trigger' });
454+
const pinnedNode = createNodeData({ name: 'pinnedNode' });
455+
const destination = createNodeData({ name: 'destinationNode' });
456+
const graph = new DirectedGraph()
457+
.addNodes(trigger, destination, pinnedNode)
458+
.addConnections({ from: trigger, to: pinnedNode }, { from: pinnedNode, to: destination });
459+
const pinData: IPinData = { [pinnedNode.name]: [{ json: { value: 1 } }] };
460+
const runData: IRunData = {
461+
[trigger.name]: [toITaskData([{ data: { value: 1 } }])],
462+
};
463+
464+
// ACT
465+
const startNodes = findStartNodes({
466+
graph,
467+
trigger,
468+
destination,
469+
runData,
470+
pinData,
471+
});
472+
473+
// ASSERT
474+
expect(startNodes.size).toBe(1);
475+
expect(startNodes).toContain(destination);
476+
});
477+
});
478+
446479
describe('custom loop logic', () => {
480+
// ►►
481+
// ┌────┐0 ┌─────────┐
482+
// ┌───────┐1 │ ├───►afterLoop│
483+
// │trigger├─┬─►loop│1 └─────────┘
484+
// └───────┘ │ │ ├─┐ ┌──────┐1
485+
// │ └────┘ └─►inLoop├──┐
486+
// │ └──────┘ │
487+
// └────────────────────┘
488+
//
447489
test('if the last run of loop node has no data (null) on the done output, then the loop is the start node', () => {
448490
// ARRANGE
449491
const trigger = createNodeData({ name: 'trigger' });
@@ -482,6 +524,15 @@ describe('findStartNodes', () => {
482524
expect(startNodes).toContainEqual(loop);
483525
});
484526

527+
// ►►
528+
// ┌────┐0 ┌─────────┐
529+
// ┌───────┐1 │ ├───►afterLoop│
530+
// │trigger├─┬─►loop│1 └─────────┘
531+
// └───────┘ │ │ ├─┐ ┌──────┐1
532+
// │ └────┘ └─►inLoop├──┐
533+
// │ └──────┘ │
534+
// └────────────────────┘
535+
//
485536
test('if the last run of loop node has no data (empty array) on the done output, then the loop is the start node', () => {
486537
// ARRANGE
487538
const trigger = createNodeData({ name: 'trigger' });
@@ -527,6 +578,15 @@ describe('findStartNodes', () => {
527578
expect(startNodes).toContainEqual(loop);
528579
});
529580

581+
// ►►
582+
// ┌────┐1 ┌─────────┐
583+
// ┌───────┐1 │ ├───►afterLoop│
584+
// │trigger├─┬─►loop│1 └─────────┘
585+
// └───────┘ │ │ ├─┐ ┌──────┐1
586+
// │ └────┘ └─►inLoop├──┐
587+
// │ └──────┘ │
588+
// └────────────────────┘
589+
//
530590
test('if the loop has data on the done output in the last run it does not become a start node', () => {
531591
// ARRANGE
532592
const trigger = createNodeData({ name: 'trigger' });

‎packages/core/src/execution-engine/partial-execution-utils/find-start-nodes.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ function findStartNodesRecursive(
111111
// If the node has multiple outputs, only follow the outputs that have run data.
112112
const hasNoRunData =
113113
nodeRunData === null || nodeRunData === undefined || nodeRunData.data.length === 0;
114-
if (hasNoRunData) {
114+
const hasNoPinnedData = pinData[outGoingConnection.from.name] === undefined;
115+
if (hasNoRunData && hasNoPinnedData) {
115116
continue;
116117
}
117118

0 commit comments

Comments
 (0)
Please sign in to comment.