fix(core): Do not emit workflow-post-execute event for waiting executions (#13065)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™ 2025-02-06 13:37:13 +01:00 committed by GitHub
parent a37c8e8fb8
commit 1593b6cb41
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 8 additions and 30 deletions

View file

@ -1155,22 +1155,6 @@ describe('TelemetryEventRelay', () => {
expect(telemetry.trackWorkflowExecution).not.toHaveBeenCalled();
});
it('should not track when execution status is "waiting"', async () => {
const event: RelayEventMap['workflow-post-execute'] = {
workflow: mockWorkflowBase,
executionId: 'execution123',
userId: 'user123',
runData: {
status: 'waiting',
data: { resultData: {} },
} as IRun,
};
eventService.emit('workflow-post-execute', event);
expect(telemetry.trackWorkflowExecution).not.toHaveBeenCalled();
});
it('should track successful workflow execution', async () => {
const runData = mock<IRun>({
finished: true,

View file

@ -600,11 +600,6 @@ export class TelemetryEventRelay extends EventRelay {
return;
}
if (runData?.status === 'waiting') {
// No need to send telemetry or logs when the workflow hasn't finished yet.
return;
}
const telemetryProperties: IExecutionTrackProperties = {
workflow_id: workflow.id,
is_manual: false,

View file

@ -126,6 +126,12 @@ describe('Execution Lifecycle Hooks', () => {
workflow: workflowData,
});
});
it('should not emit workflow-post-execute events for waiting executions', async () => {
await hooks.executeHookFunctions('workflowExecuteAfter', [waitingRun, {}]);
expect(eventService.emit).not.toHaveBeenCalledWith('workflow-post-execute');
});
});
};

View file

@ -68,6 +68,8 @@ function hookFunctionsWorkflowEvents(userId?: string): IWorkflowExecuteHooks {
],
workflowExecuteAfter: [
async function (this: WorkflowHooks, runData: IRun): Promise<void> {
if (runData.status === 'waiting') return;
const { executionId, workflowData: workflow } = this;
eventService.emit('workflow-post-execute', { executionId, runData, workflow, userId });
},

View file

@ -37,7 +37,6 @@ describe('ExecutionRecoveryService', () => {
instanceSettings,
push,
executionRepository,
mock(),
);
});

View file

@ -8,7 +8,6 @@ import { ARTIFICIAL_TASK_DATA } from '@/constants';
import { ExecutionRepository } from '@/databases/repositories/execution.repository';
import { NodeCrashedError } from '@/errors/node-crashed.error';
import { WorkflowCrashedError } from '@/errors/workflow-crashed.error';
import { EventService } from '@/events/event.service';
import { getWorkflowHooksMain } from '@/execution-lifecycle/execution-lifecycle-hooks';
import type { IExecutionResponse } from '@/interfaces';
import { Push } from '@/push';
@ -25,7 +24,6 @@ export class ExecutionRecoveryService {
private readonly instanceSettings: InstanceSettings,
private readonly push: Push,
private readonly executionRepository: ExecutionRepository,
private readonly eventService: EventService,
) {}
/**
@ -176,12 +174,6 @@ export class ExecutionRecoveryService {
private async runHooks(execution: IExecutionResponse) {
execution.data ??= { resultData: { runData: {} } };
this.eventService.emit('workflow-post-execute', {
workflow: execution.workflowData,
executionId: execution.id,
runData: execution,
});
const externalHooks = getWorkflowHooksMain(
{
userId: '',