-
Notifications
You must be signed in to change notification settings - Fork 8.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(core): Remove circular dependency in WorkflowService and ActiveWo…
…rkflowRunner (#8128) 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. - [x] PR title and summary are descriptive - [ ] Tests included
- Loading branch information
Showing
9 changed files
with
99 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { Service } from 'typedi'; | ||
import { type IDataObject, type Workflow, ErrorReporterProxy as ErrorReporter } from 'n8n-workflow'; | ||
import { Logger } from '@/Logger'; | ||
import { WorkflowRepository } from '@db/repositories/workflow.repository'; | ||
import { isWorkflowIdValid } from '@/utils'; | ||
|
||
@Service() | ||
export class WorkflowStaticDataService { | ||
constructor( | ||
private readonly logger: Logger, | ||
private readonly workflowRepository: WorkflowRepository, | ||
) {} | ||
|
||
/** Saves the static data if it changed */ | ||
async saveStaticData(workflow: Workflow): Promise<void> { | ||
if (workflow.staticData.__dataChanged === true) { | ||
// Static data of workflow changed and so has to be saved | ||
if (isWorkflowIdValid(workflow.id)) { | ||
// Workflow is saved so update in database | ||
try { | ||
await this.saveStaticDataById(workflow.id, workflow.staticData); | ||
workflow.staticData.__dataChanged = false; | ||
} catch (error) { | ||
ErrorReporter.error(error); | ||
this.logger.error( | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access | ||
`There was a problem saving the workflow with id "${workflow.id}" to save changed Data: "${error.message}"`, | ||
{ workflowId: workflow.id }, | ||
); | ||
} | ||
} | ||
} | ||
} | ||
|
||
/** Saves the given static data on workflow */ | ||
async saveStaticDataById(workflowId: string, newStaticData: IDataObject): Promise<void> { | ||
await this.workflowRepository.update(workflowId, { | ||
staticData: newStaticData, | ||
}); | ||
} | ||
} |
Oops, something went wrong.