fix(core): Skip canceled executions in unfinished execution recovery (#19452)

Co-authored-by: Danny Martini <danny@n8n.io>
This commit is contained in:
Mutasem Aldmour
2025-09-12 15:34:53 +02:00
committed by GitHub
parent 1853faf032
commit b388b230c9
2 changed files with 29 additions and 1 deletions

View File

@@ -175,6 +175,31 @@ describe('ExecutionRecoveryService', () => {
expect(amendedExecution).toBeNull();
});
test('for canceled executions with data, should return `null`', async () => {
/**
* Arrange
*/
const workflow = await createWorkflow();
const execution = await createExecution(
{ status: 'canceled', data: stringify({ runData: {} }) },
workflow,
);
const messages = setupMessages(execution.id, 'Some workflow');
/**
* Act
*/
const amendedExecution = await executionRecoveryService.recoverFromLogs(
execution.id,
messages,
);
/**
* Assert
*/
expect(amendedExecution).toBeNull();
});
test('should return `null` if no execution found', async () => {
/**
* Arrange

View File

@@ -77,7 +77,10 @@ export class ExecutionRecoveryService {
* because execution lifecycle hooks cause worker event logs to be partitioned.
* Hence we need to filter out finished executions here.
* */
if (!execution || (['success', 'error'].includes(execution.status) && execution.data)) {
if (
!execution ||
(['success', 'error', 'canceled'].includes(execution.status) && execution.data)
) {
return null;
}