Skip to content

Commit a217866

Browse files
authored
fix(core): Account for retry of execution aborted by pre-execute hook (#9474)
1 parent 3094f1b commit a217866

File tree

4 files changed

+43
-1
lines changed

4 files changed

+43
-1
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { ApplicationError } from 'n8n-workflow';
2+
3+
export class AbortedExecutionRetryError extends ApplicationError {
4+
constructor() {
5+
super('The execution was aborted before starting, so it cannot be retried', {
6+
level: 'warning',
7+
});
8+
}
9+
}

packages/cli/src/executions/execution.service.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import { NotFoundError } from '@/errors/response-errors/not-found.error';
3636
import config from '@/config';
3737
import { WaitTracker } from '@/WaitTracker';
3838
import type { ExecutionEntity } from '@/databases/entities/ExecutionEntity';
39+
import { AbortedExecutionRetryError } from '@/errors/aborted-execution-retry.error';
3940

4041
export const schemaGetExecutionsQueryFilter = {
4142
$id: '/IGetExecutionsQueryFilter',
@@ -129,6 +130,8 @@ export class ExecutionService {
129130
throw new NotFoundError(`The execution with the ID "${executionId}" does not exist.`);
130131
}
131132

133+
if (!execution.data.executionData) throw new AbortedExecutionRetryError();
134+
132135
if (execution.finished) {
133136
throw new ApplicationError('The execution succeeded, so it cannot be retried.');
134137
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import type { IExecutionResponse } from '@/Interfaces';
2+
import type { ExecutionRepository } from '@/databases/repositories/execution.repository';
3+
import { AbortedExecutionRetryError } from '@/errors/aborted-execution-retry.error';
4+
import { ExecutionService } from '@/executions/execution.service';
5+
import type { ExecutionRequest } from '@/executions/execution.types';
6+
import { mock } from 'jest-mock-extended';
7+
8+
describe('ExecutionService', () => {
9+
const executionRepository = mock<ExecutionRepository>();
10+
const executionService = new ExecutionService(
11+
mock(),
12+
mock(),
13+
mock(),
14+
executionRepository,
15+
mock(),
16+
mock(),
17+
mock(),
18+
mock(),
19+
);
20+
21+
it('should error on retrying an aborted execution', async () => {
22+
const abortedExecutionData = mock<IExecutionResponse>({ data: { executionData: undefined } });
23+
executionRepository.findWithUnflattenedData.mockResolvedValue(abortedExecutionData);
24+
const req = mock<ExecutionRequest.Retry>();
25+
26+
const retry = executionService.retry(req, []);
27+
28+
await expect(retry).rejects.toThrow(AbortedExecutionRetryError);
29+
});
30+
});

packages/editor-ui/src/plugins/i18n/locales/en.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1218,7 +1218,7 @@
12181218
"nodeView.runButtonText.executeWorkflow": "Test workflow",
12191219
"nodeView.runButtonText.executingWorkflow": "Executing workflow",
12201220
"nodeView.runButtonText.waitingForTriggerEvent": "Waiting for trigger event",
1221-
"nodeView.showError.workflowError": "Workflow execution finished with an error",
1221+
"nodeView.showError.workflowError": "Workflow execution had an error",
12221222
"nodeView.showError.getWorkflowDataFromUrl.title": "Problem loading workflow",
12231223
"nodeView.showError.importWorkflowData.title": "Problem importing workflow",
12241224
"nodeView.showError.mounted1.message": "There was a problem loading init data",

0 commit comments

Comments
 (0)