diff --git a/packages/cli/src/errors/max-stalled-count.error.ts b/packages/cli/src/errors/max-stalled-count.error.ts index 653ca18eacac7..38f73023a7485 100644 --- a/packages/cli/src/errors/max-stalled-count.error.ts +++ b/packages/cli/src/errors/max-stalled-count.error.ts @@ -5,9 +5,12 @@ import { ApplicationError } from 'n8n-workflow'; */ export class MaxStalledCountError extends ApplicationError { constructor(cause: Error) { - super('The execution has reached the maximum number of attempts and will no longer retry.', { - level: 'warning', - cause, - }); + super( + 'This execution failed to be processed too many times and will no longer retry. To allow this execution to complete, please break down your workflow or scale up your workers or adjust your worker settings.', + { + level: 'warning', + cause, + }, + ); } } diff --git a/packages/cli/src/scaling/scaling.service.ts b/packages/cli/src/scaling/scaling.service.ts index f20d0764c6aa9..7c48ce57e2632 100644 --- a/packages/cli/src/scaling/scaling.service.ts +++ b/packages/cli/src/scaling/scaling.service.ts @@ -17,7 +17,6 @@ import config from '@/config'; import { HIGHEST_SHUTDOWN_PRIORITY, Time } from '@/constants'; import { ExecutionRepository } from '@/databases/repositories/execution.repository'; import { OnShutdown } from '@/decorators/on-shutdown'; -import { MaxStalledCountError } from '@/errors/max-stalled-count.error'; import { EventService } from '@/events/event.service'; import { OrchestrationService } from '@/services/orchestration.service'; import { assertNever } from '@/utils'; @@ -271,10 +270,6 @@ export class ScalingService { this.queue.on('error', (error: Error) => { if ('code' in error && error.code === 'ECONNREFUSED') return; // handled by RedisClientService.retryStrategy - if (error.message.includes('job stalled more than maxStalledCount')) { - throw new MaxStalledCountError(error); - } - /** * Non-recoverable error on worker start with Redis unavailable. * Even if Redis recovers, worker will remain unable to process jobs. diff --git a/packages/cli/src/workflow-runner.ts b/packages/cli/src/workflow-runner.ts index 148df7edcd8bb..f68eff09ed626 100644 --- a/packages/cli/src/workflow-runner.ts +++ b/packages/cli/src/workflow-runner.ts @@ -37,6 +37,8 @@ import * as WorkflowExecuteAdditionalData from '@/workflow-execute-additional-da import { generateFailedExecutionFromError } from '@/workflow-helpers'; import { WorkflowStaticDataService } from '@/workflows/workflow-static-data.service'; +import { MaxStalledCountError } from './errors/max-stalled-count.error'; + @Service() export class WorkflowRunner { private scalingService: ScalingService; @@ -424,6 +426,14 @@ export class WorkflowRunner { data.workflowData, { retryOf: data.retryOf ? data.retryOf.toString() : undefined }, ); + + if ( + error instanceof Error && + error.message.includes('job stalled more than maxStalledCount') + ) { + error = new MaxStalledCountError(error); + } + await this.processError(error, new Date(), data.executionMode, executionId, hooks); reject(error);