mirror of
https://github.com/n8n-io/n8n.git
synced 2025-02-21 02:56:40 -08:00
fix(core): Do not emit workflow-post-execute
event for waiting executions (#13065)
This commit is contained in:
parent
a37c8e8fb8
commit
1593b6cb41
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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');
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -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 });
|
||||
},
|
||||
|
|
|
@ -37,7 +37,6 @@ describe('ExecutionRecoveryService', () => {
|
|||
instanceSettings,
|
||||
push,
|
||||
executionRepository,
|
||||
mock(),
|
||||
);
|
||||
});
|
||||
|
||||
|
|
|
@ -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: '',
|
||||
|
|
Loading…
Reference in a new issue