-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(core): Account for retry of execution aborted by pre-execute hook
- Loading branch information
Showing
4 changed files
with
43 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { ApplicationError } from 'n8n-workflow'; | ||
|
||
export class AbortedExecutionRetryError extends ApplicationError { | ||
constructor() { | ||
super('The execution was aborted before starting, so it cannot be retried', { | ||
level: 'warning', | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import type { IExecutionResponse } from '@/Interfaces'; | ||
import type { ExecutionRepository } from '@/databases/repositories/execution.repository'; | ||
import { AbortedExecutionRetryError } from '@/errors/aborted-execution-retry.error'; | ||
import { ExecutionService } from '@/executions/execution.service'; | ||
import type { ExecutionRequest } from '@/executions/execution.types'; | ||
import { mock } from 'jest-mock-extended'; | ||
|
||
describe('ExecutionService', () => { | ||
const executionRepository = mock<ExecutionRepository>(); | ||
const executionService = new ExecutionService( | ||
mock(), | ||
mock(), | ||
mock(), | ||
executionRepository, | ||
mock(), | ||
mock(), | ||
mock(), | ||
mock(), | ||
); | ||
|
||
it('should error on retrying an aborted execution', async () => { | ||
const abortedExecutionData = mock<IExecutionResponse>({ data: { executionData: undefined } }); | ||
executionRepository.findWithUnflattenedData.mockResolvedValue(abortedExecutionData); | ||
const req = mock<ExecutionRequest.Retry>(); | ||
|
||
const retry = executionService.retry(req, []); | ||
|
||
await expect(retry).rejects.toThrow(AbortedExecutionRetryError); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters