refactor(core): Better UX for maxStalledCount queue mode error (#9075)

This commit is contained in:
Iván Ovejero 2024-04-05 20:03:49 +02:00 committed by GitHub
parent 7bf0f900f1
commit df56153f8b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 19 additions and 0 deletions

View file

@ -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;
}
});

View file

@ -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,
});
}
}