Skip to content

Commit

Permalink
Fix issue with workflow process to initialize db connection correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
krynble committed Mar 7, 2022
1 parent ea40412 commit 50a810c
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions packages/cli/src/WorkflowRunnerProcess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,18 @@ export class WorkflowRunnerProcess {
// We check if any node uses credentials. If it does, then
// init database.
let shouldInitializaDb = false;
// eslint-disable-next-line array-callback-return
inputData.workflowData.nodes.map((node) => {
inputData.workflowData.nodes.some((node) => {
// Stop as soon as we find a node that uses credentials or
// execute workflow node. Both these will need DB access.
if (Object.keys(node.credentials === undefined ? {} : node.credentials).length > 0) {
shouldInitializaDb = true;
return true;
}
if (node.type === 'n8n-nodes-base.executeWorkflow') {
shouldInitializaDb = true;
return true;
}
return false;
});

// This code has been split into 4 ifs just to make it easier to understand
Expand Down Expand Up @@ -237,7 +244,9 @@ export class WorkflowRunnerProcess {
staticData: this.data.workflowData.staticData,
settings: this.data.workflowData.settings,
});
await checkPermissionsForExecution(this.workflow, userId);
if (shouldInitializaDb) {
await checkPermissionsForExecution(this.workflow, userId);
}
const additionalData = await WorkflowExecuteAdditionalData.getBase(
userId,
undefined,
Expand Down

0 comments on commit 50a810c

Please sign in to comment.