diff --git a/packages/cli/src/commands/worker.ts b/packages/cli/src/commands/worker.ts index faee68cc58..965a6ac289 100644 --- a/packages/cli/src/commands/worker.ts +++ b/packages/cli/src/commands/worker.ts @@ -29,6 +29,7 @@ import { OrchestrationWorkerService } from '@/services/orchestration/worker/orch import type { WorkerJobStatusSummary } from '@/services/orchestration/worker/types'; import { ServiceUnavailableError } from '@/errors/response-errors/service-unavailable.error'; import { BaseCommand } from './BaseCommand'; +import { MaxStalledCountError } from '@/errors/max-stalled-count.error'; export class Worker extends BaseCommand { static description = '\nStarts a n8n worker'; @@ -366,6 +367,11 @@ export class Worker extends BaseCommand { process.exit(2); } else { this.logger.error('Error from queue: ', error); + + if (error.message.includes('job stalled more than maxStalledCount')) { + throw new MaxStalledCountError(error); + } + throw error; } }); diff --git a/packages/cli/src/errors/max-stalled-count.error.ts b/packages/cli/src/errors/max-stalled-count.error.ts new file mode 100644 index 0000000000..6715de0ade --- /dev/null +++ b/packages/cli/src/errors/max-stalled-count.error.ts @@ -0,0 +1,13 @@ +import { ApplicationError } from 'n8n-workflow'; + +/** + * See https://github.com/OptimalBits/bull/blob/60fa88f08637f0325639988a3f054880a04ce402/docs/README.md?plain=1#L133 + */ +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, + }); + } +}