mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 10:31:15 +00:00
refactor(core): Stronger typing for workflow settings (no-changelog) (#5754)
This commit is contained in:
committed by
GitHub
parent
d33a1ac1e9
commit
c9d9069c0e
@@ -136,17 +136,11 @@ export function executeErrorWorkflow(
|
||||
|
||||
// Run the error workflow
|
||||
// To avoid an infinite loop do not run the error workflow again if the error-workflow itself failed and it is its own error-workflow.
|
||||
if (
|
||||
workflowData.settings?.errorWorkflow &&
|
||||
!(
|
||||
mode === 'error' &&
|
||||
workflowId &&
|
||||
workflowData.settings.errorWorkflow.toString() === workflowId
|
||||
)
|
||||
) {
|
||||
const { errorWorkflow } = workflowData.settings ?? {};
|
||||
if (errorWorkflow && !(mode === 'error' && workflowId && errorWorkflow === workflowId)) {
|
||||
Logger.verbose('Start external error workflow', {
|
||||
executionId,
|
||||
errorWorkflowId: workflowData.settings.errorWorkflow.toString(),
|
||||
errorWorkflowId: errorWorkflow,
|
||||
workflowId,
|
||||
});
|
||||
// If a specific error workflow is set run only that one
|
||||
@@ -160,11 +154,7 @@ export function executeErrorWorkflow(
|
||||
}
|
||||
getWorkflowOwner(workflowId)
|
||||
.then((user) => {
|
||||
void WorkflowHelpers.executeErrorWorkflow(
|
||||
workflowData.settings!.errorWorkflow as string,
|
||||
workflowErrorData,
|
||||
user,
|
||||
);
|
||||
void WorkflowHelpers.executeErrorWorkflow(errorWorkflow, workflowErrorData, user);
|
||||
})
|
||||
.catch((error: Error) => {
|
||||
ErrorReporter.error(error);
|
||||
@@ -172,7 +162,7 @@ export function executeErrorWorkflow(
|
||||
`Could not execute ErrorWorkflow for execution ID ${this.executionId} because of error querying the workflow owner`,
|
||||
{
|
||||
executionId,
|
||||
errorWorkflowId: workflowData.settings!.errorWorkflow!.toString(),
|
||||
errorWorkflowId: errorWorkflow,
|
||||
workflowId,
|
||||
error,
|
||||
workflowErrorData,
|
||||
@@ -421,21 +411,21 @@ export function hookFunctionsPreExecute(parentProcessMode?: string): IWorkflowEx
|
||||
],
|
||||
nodeExecuteAfter: [
|
||||
async function (
|
||||
this: WorkflowHooks,
|
||||
nodeName: string,
|
||||
data: ITaskData,
|
||||
executionData: IRunExecutionData,
|
||||
): Promise<void> {
|
||||
if (this.workflowData.settings !== undefined) {
|
||||
if (this.workflowData.settings.saveExecutionProgress === false) {
|
||||
const saveExecutionProgress = config.getEnv('executions.saveExecutionProgress');
|
||||
const workflowSettings = this.workflowData.settings;
|
||||
if (workflowSettings !== undefined) {
|
||||
if (workflowSettings.saveExecutionProgress === false) {
|
||||
return;
|
||||
}
|
||||
if (
|
||||
this.workflowData.settings.saveExecutionProgress !== true &&
|
||||
!config.getEnv('executions.saveExecutionProgress')
|
||||
) {
|
||||
if (workflowSettings.saveExecutionProgress !== true && !saveExecutionProgress) {
|
||||
return;
|
||||
}
|
||||
} else if (!config.getEnv('executions.saveExecutionProgress')) {
|
||||
} else if (!saveExecutionProgress) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -563,13 +553,11 @@ function hookFunctionsSave(parentProcessMode?: string): IWorkflowExecuteHooks {
|
||||
}
|
||||
}
|
||||
|
||||
const workflowSettings = this.workflowData.settings;
|
||||
let saveManualExecutions = config.getEnv('executions.saveDataManualExecutions');
|
||||
if (
|
||||
this.workflowData.settings !== undefined &&
|
||||
this.workflowData.settings.saveManualExecutions !== undefined
|
||||
) {
|
||||
if (workflowSettings?.saveManualExecutions !== undefined) {
|
||||
// Apply to workflow override
|
||||
saveManualExecutions = this.workflowData.settings.saveManualExecutions as boolean;
|
||||
saveManualExecutions = workflowSettings.saveManualExecutions as boolean;
|
||||
}
|
||||
|
||||
if (isManualMode && !saveManualExecutions && !fullRunData.waitTill) {
|
||||
@@ -1024,16 +1012,14 @@ async function executeWorkflow(
|
||||
additionalDataIntegrated.executeWorkflow = additionalData.executeWorkflow;
|
||||
|
||||
let subworkflowTimeout = additionalData.executionTimeoutTimestamp;
|
||||
if (
|
||||
workflowData.settings?.executionTimeout !== undefined &&
|
||||
workflowData.settings.executionTimeout > 0
|
||||
) {
|
||||
const workflowSettings = workflowData.settings;
|
||||
if (workflowSettings?.executionTimeout !== undefined && workflowSettings.executionTimeout > 0) {
|
||||
// We might have received a max timeout timestamp from the parent workflow
|
||||
// If we did, then we get the minimum time between the two timeouts
|
||||
// If no timeout was given from the parent, then we use our timeout.
|
||||
subworkflowTimeout = Math.min(
|
||||
additionalData.executionTimeoutTimestamp || Number.MAX_SAFE_INTEGER,
|
||||
Date.now() + (workflowData.settings.executionTimeout as number) * 1000,
|
||||
Date.now() + workflowSettings.executionTimeout * 1000,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user