mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
🐛 Fix that static data did not always get load on execution
This commit is contained in:
@@ -263,7 +263,7 @@ export class ActiveWorkflowRunner {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const workflowRunner = new WorkflowRunner();
|
const workflowRunner = new WorkflowRunner();
|
||||||
workflowRunner.run(runData);
|
workflowRunner.run(runData, true);
|
||||||
};
|
};
|
||||||
return returnFunctions;
|
return returnFunctions;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -224,7 +224,7 @@ export function getWorkflowWebhooks(workflow: Workflow, additionalData: IWorkflo
|
|||||||
|
|
||||||
// Start now to run the workflow
|
// Start now to run the workflow
|
||||||
const workflowRunner = new WorkflowRunner();
|
const workflowRunner = new WorkflowRunner();
|
||||||
const executionId = await workflowRunner.run(runData);
|
const executionId = await workflowRunner.run(runData, true);
|
||||||
|
|
||||||
// Get a promise which resolves when the workflow did execute and send then response
|
// Get a promise which resolves when the workflow did execute and send then response
|
||||||
const executePromise = activeExecutions.getPostExecutePromise(executionId) as Promise<IExecutionDb | undefined>;
|
const executePromise = activeExecutions.getPostExecutePromise(executionId) as Promise<IExecutionDb | undefined>;
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ const hooks = (mode: WorkflowExecuteMode, workflowData: IWorkflowBase, execution
|
|||||||
workflowExecuteAfter: [
|
workflowExecuteAfter: [
|
||||||
async (fullRunData: IRun, newStaticData: IDataObject): Promise<void> => {
|
async (fullRunData: IRun, newStaticData: IDataObject): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
if (WorkflowHelpers.isWorkflowIdValid(workflowData.id as string) === true) {
|
if (mode !== 'manual' && WorkflowHelpers.isWorkflowIdValid(workflowData.id as string) === true) {
|
||||||
// Workflow is saved so update in database
|
// Workflow is saved so update in database
|
||||||
try {
|
try {
|
||||||
await WorkflowHelpers.saveStaticDataById(workflowData.id as string, newStaticData);
|
await WorkflowHelpers.saveStaticDataById(workflowData.id as string, newStaticData);
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ export async function executeErrorWorkflow(workflowId: string, workflowErrorData
|
|||||||
const executionMode = 'error';
|
const executionMode = 'error';
|
||||||
const nodeTypes = NodeTypes();
|
const nodeTypes = NodeTypes();
|
||||||
|
|
||||||
const workflowInstance = new Workflow(workflowId, workflowData.nodes, workflowData.connections, workflowData.active, nodeTypes, undefined, workflowData.settings);
|
const workflowInstance = new Workflow(workflowId, workflowData.nodes, workflowData.connections, workflowData.active, nodeTypes, workflowData.staticData, workflowData.settings);
|
||||||
|
|
||||||
|
|
||||||
let node: INode;
|
let node: INode;
|
||||||
@@ -168,3 +168,23 @@ export async function saveStaticDataById(workflowId: string | number, newStaticD
|
|||||||
staticData: newStaticData,
|
staticData: newStaticData,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the static data of workflow
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
* @param {(string | number)} workflowId The id of the workflow to get static data of
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export async function getStaticDataById(workflowId: string | number) {
|
||||||
|
const workflowData = await Db.collections.Workflow!
|
||||||
|
.findOne(workflowId, { select: ['staticData']});
|
||||||
|
|
||||||
|
if (workflowData === undefined) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
return workflowData.staticData || {};
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import {
|
|||||||
NodeTypes,
|
NodeTypes,
|
||||||
Push,
|
Push,
|
||||||
WorkflowExecuteAdditionalData,
|
WorkflowExecuteAdditionalData,
|
||||||
|
WorkflowHelpers,
|
||||||
} from './';
|
} from './';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -140,13 +141,19 @@ export class WorkflowRunner {
|
|||||||
* Run the workflow in subprocess
|
* Run the workflow in subprocess
|
||||||
*
|
*
|
||||||
* @param {IWorkflowExecutionDataProcess} data
|
* @param {IWorkflowExecutionDataProcess} data
|
||||||
|
* @param {boolean} [loadStaticData] If set will the static data be loaded from
|
||||||
|
* the workflow and added to input data
|
||||||
* @returns {Promise<string>}
|
* @returns {Promise<string>}
|
||||||
* @memberof WorkflowRunner
|
* @memberof WorkflowRunner
|
||||||
*/
|
*/
|
||||||
async run(data: IWorkflowExecutionDataProcess): Promise<string> {
|
async run(data: IWorkflowExecutionDataProcess, loadStaticData?: boolean): Promise<string> {
|
||||||
const startedAt = new Date();
|
const startedAt = new Date();
|
||||||
const subprocess = fork(pathJoin(__dirname, 'WorkflowRunnerProcess.js'));
|
const subprocess = fork(pathJoin(__dirname, 'WorkflowRunnerProcess.js'));
|
||||||
|
|
||||||
|
if (loadStaticData === true && data.workflowData.id) {
|
||||||
|
data.workflowData.staticData = await WorkflowHelpers.getStaticDataById(data.workflowData.id as string);
|
||||||
|
}
|
||||||
|
|
||||||
// Register the active execution
|
// Register the active execution
|
||||||
const executionId = this.activeExecutions.add(subprocess, data);
|
const executionId = this.activeExecutions.add(subprocess, data);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user