Skip to content

Commit 426a12a

Browse files
authored
fix(editor): Prevent excess runs in manual execution with run data (#9259)
1 parent 9f6f8ea commit 426a12a

File tree

3 files changed

+138
-3
lines changed

3 files changed

+138
-3
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { NDV, WorkflowPage } from '../pages';
2+
3+
const canvas = new WorkflowPage();
4+
const ndv = new NDV();
5+
6+
describe('Manual partial execution', () => {
7+
it('should execute parent nodes with no run data only once', () => {
8+
canvas.actions.visit();
9+
10+
cy.fixture('manual-partial-execution.json').then((data) => {
11+
cy.get('body').paste(JSON.stringify(data));
12+
});
13+
14+
canvas.actions.zoomToFit();
15+
16+
canvas.actions.openNode('Edit Fields');
17+
18+
cy.get('button').contains('Test step').click(); // create run data
19+
cy.get('button').contains('Test step').click(); // use run data
20+
21+
ndv.actions.close();
22+
23+
canvas.actions.openNode('Webhook1');
24+
25+
ndv.getters.nodeRunSuccessIndicator().should('exist');
26+
ndv.getters.outputRunSelector().should('not.exist'); // single run
27+
});
28+
});
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
{
2+
"meta": {
3+
"templateCredsSetupCompleted": true
4+
},
5+
"nodes": [
6+
{
7+
"parameters": {
8+
"options": {}
9+
},
10+
"id": "f4467143-fdb9-46fa-8020-6417cc5eea7d",
11+
"name": "Edit Fields",
12+
"type": "n8n-nodes-base.set",
13+
"typeVersion": 3.3,
14+
"position": [
15+
1140,
16+
260
17+
]
18+
},
19+
{
20+
"parameters": {
21+
"path": "30ff316d-405f-4288-a0ac-e713546c9d4e",
22+
"options": {}
23+
},
24+
"id": "4760aafb-5d56-4633-99d3-7a97c576a216",
25+
"name": "Webhook1",
26+
"type": "n8n-nodes-base.webhook",
27+
"typeVersion": 2,
28+
"position": [
29+
680,
30+
340
31+
],
32+
"webhookId": "30ff316d-405f-4288-a0ac-e713546c9d4e"
33+
},
34+
{
35+
"parameters": {
36+
"articleId": "123",
37+
"additionalFields": {}
38+
},
39+
"id": "8c811eca-8978-44d9-b8f7-ef2c7725784c",
40+
"name": "Hacker News",
41+
"type": "n8n-nodes-base.hackerNews",
42+
"typeVersion": 1,
43+
"position": [
44+
920,
45+
260
46+
]
47+
},
48+
{
49+
"parameters": {
50+
"path": "4a3398e4-1388-4e10-9d21-add90b804955",
51+
"options": {}
52+
},
53+
"id": "1c2c2d06-45c9-4712-9fa0-c655bef8d0e5",
54+
"name": "Webhook",
55+
"type": "n8n-nodes-base.webhook",
56+
"typeVersion": 2,
57+
"position": [
58+
680,
59+
180
60+
],
61+
"webhookId": "4a3398e4-1388-4e10-9d21-add90b804955"
62+
}
63+
],
64+
"connections": {
65+
"Webhook1": {
66+
"main": [
67+
[
68+
{
69+
"node": "Hacker News",
70+
"type": "main",
71+
"index": 0
72+
}
73+
]
74+
]
75+
},
76+
"Hacker News": {
77+
"main": [
78+
[
79+
{
80+
"node": "Edit Fields",
81+
"type": "main",
82+
"index": 0
83+
}
84+
]
85+
]
86+
},
87+
"Webhook": {
88+
"main": [
89+
[
90+
{
91+
"node": "Hacker News",
92+
"type": "main",
93+
"index": 0
94+
}
95+
]
96+
]
97+
}
98+
},
99+
"pinData": {
100+
"Webhook": [
101+
{
102+
"name": "First item",
103+
"code": 1
104+
}
105+
]
106+
}
107+
}

packages/editor-ui/src/composables/useRunWorkflow.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ export function useRunWorkflow(useRunWorkflowOpts: { router: ReturnType<typeof u
334334
pinData: IPinData | undefined,
335335
workflow: Workflow,
336336
): { runData: IRunData | undefined; startNodeNames: string[] } {
337-
const startNodeNames: string[] = [];
337+
const startNodeNames = new Set<string>();
338338
let newRunData: IRunData | undefined;
339339

340340
if (runData !== null && Object.keys(runData).length !== 0) {
@@ -360,7 +360,7 @@ export function useRunWorkflow(useRunWorkflowOpts: { router: ReturnType<typeof u
360360
// When we hit a node which has no data we stop and set it
361361
// as a start node the execution from and then go on with other
362362
// direct input nodes
363-
startNodeNames.push(parentNode);
363+
startNodeNames.add(parentNode);
364364
break;
365365
}
366366
if (runData[parentNode] && !runData[parentNode]?.[0]?.error) {
@@ -376,7 +376,7 @@ export function useRunWorkflow(useRunWorkflowOpts: { router: ReturnType<typeof u
376376
}
377377
}
378378

379-
return { runData: newRunData, startNodeNames };
379+
return { runData: newRunData, startNodeNames: [...startNodeNames] };
380380
}
381381

382382
async function stopCurrentExecution() {

0 commit comments

Comments
 (0)