fix(core): Remove circular dependency in WorkflowService and ActiveWorkflowRunner (#8128)

## Summary
A circular dependency between `WorkflowService` and
`ActiveWorkflowRunner` is sometimes causing `this.activeWorkflowRunner`
to be `undefined` in `WorkflowService`.
Breaking this circular dependency should hopefully fix this issue.

## Related tickets and issues
#8122


## Review / Merge checklist
- [x] PR title and summary are descriptive
- [ ] Tests included
This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2023-12-21 17:37:08 +01:00
committed by GitHub
parent e9c7fd7397
commit 21788d9153
9 changed files with 98 additions and 86 deletions

View File

@@ -52,7 +52,6 @@ import * as WebhookHelpers from '@/WebhookHelpers';
import * as WorkflowHelpers from '@/WorkflowHelpers';
import { findSubworkflowStart, isWorkflowIdValid } from '@/utils';
import { PermissionChecker } from './UserManagement/PermissionChecker';
import { WorkflowService } from './workflows/workflow.service';
import { InternalHooks } from '@/InternalHooks';
import { ExecutionRepository } from '@db/repositories/execution.repository';
import { EventsService } from '@/services/events.service';
@@ -67,6 +66,8 @@ import { restoreBinaryDataId } from './executionLifecycleHooks/restoreBinaryData
import { toSaveSettings } from './executionLifecycleHooks/toSaveSettings';
import { Logger } from './Logger';
import { saveExecutionProgress } from './executionLifecycleHooks/saveExecutionProgress';
import { WorkflowStaticDataService } from './workflows/workflowStaticData.service';
import { WorkflowRepository } from './databases/repositories/workflow.repository';
const ERROR_TRIGGER_TYPE = config.getEnv('nodes.errorTriggerType');
@@ -418,7 +419,7 @@ function hookFunctionsSave(parentProcessMode?: string): IWorkflowExecuteHooks {
if (!isManualMode && isWorkflowIdValid(this.workflowData.id) && newStaticData) {
// Workflow is saved so update in database
try {
await Container.get(WorkflowService).saveStaticDataById(
await Container.get(WorkflowStaticDataService).saveStaticDataById(
this.workflowData.id as string,
newStaticData,
);
@@ -564,7 +565,7 @@ function hookFunctionsSaveWorker(): IWorkflowExecuteHooks {
if (isWorkflowIdValid(this.workflowData.id) && newStaticData) {
// Workflow is saved so update in database
try {
await Container.get(WorkflowService).saveStaticDataById(
await Container.get(WorkflowStaticDataService).saveStaticDataById(
this.workflowData.id as string,
newStaticData,
);
@@ -714,7 +715,10 @@ export async function getWorkflowData(
if (workflowInfo.id !== undefined) {
const relations = config.getEnv('workflowTagsDisabled') ? [] : ['tags'];
workflowData = await Container.get(WorkflowService).get({ id: workflowInfo.id }, { relations });
workflowData = await Container.get(WorkflowRepository).get(
{ id: workflowInfo.id },
{ relations },
);
if (workflowData === undefined || workflowData === null) {
throw new ApplicationError('Workflow does not exist.', {