Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): Handle max stalled count error better #12824

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions packages/cli/src/errors/max-stalled-count.error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
);
}
}
5 changes: 0 additions & 5 deletions packages/cli/src/scaling/scaling.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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.
Expand Down
10 changes: 10 additions & 0 deletions packages/cli/src/workflow-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Loading