1
1
mirror of https://github.com/n8n-io/n8n.git synced 2024-09-11 21:17:50 +03:00

fix(core): Fix partial execution with pinned data on child node run (#4764)

🐛 Fix partial execution with pinned data on child node run
This commit is contained in:
Iván Ovejero 2022-12-05 10:09:31 +01:00 committed by GitHub
parent 9e7a156532
commit 5d75e6ceb3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -70,6 +70,11 @@ export class WorkflowsService {
/**
* Find the pinned trigger to execute the workflow from, if any.
*
* - In a full execution, select the _first_ pinned trigger.
* - In a partial execution,
* - select the _first_ pinned trigger that leads to the executed node,
* - else select the executed pinned trigger.
*/
static findPinnedTrigger(workflow: IWorkflowDb, startNodes?: string[], pinData?: IPinData) {
if (!pinData || !startNodes) return null;
@ -87,7 +92,22 @@ export class WorkflowsService {
const [startNodeName] = startNodes;
return pinnedTriggers.find((pt) => pt.name === startNodeName) ?? null; // partial execution
const parentNames = new Workflow({
nodes: workflow.nodes,
connections: workflow.connections,
active: workflow.active,
nodeTypes: NodeTypes(),
}).getParentNodes(startNodeName);
let checkNodeName = '';
if (parentNames.length === 0) {
checkNodeName = startNodeName;
} else {
checkNodeName = parentNames.find((pn) => pn === pinnedTriggers[0].name) as string;
}
return pinnedTriggers.find((pt) => pt.name === checkNodeName) ?? null; // partial execution
}
static async get(workflow: Partial<WorkflowEntity>, options?: { relations: string[] }) {