diff --git a/packages/cli/src/webhooks/__tests__/waiting-webhooks.test.ts b/packages/cli/src/webhooks/__tests__/waiting-webhooks.test.ts index 72fe654c55..a752b46795 100644 --- a/packages/cli/src/webhooks/__tests__/waiting-webhooks.test.ts +++ b/packages/cli/src/webhooks/__tests__/waiting-webhooks.test.ts @@ -6,7 +6,7 @@ import { ConflictError } from '@/errors/response-errors/conflict.error'; import { NotFoundError } from '@/errors/response-errors/not-found.error'; import type { IExecutionResponse } from '@/interfaces'; import { WaitingWebhooks } from '@/webhooks/waiting-webhooks'; -import type { WaitingWebhookRequest } from '@/webhooks/webhook.types'; +import type { IWebhookResponseCallbackData, WaitingWebhookRequest } from '@/webhooks/webhook.types'; describe('WaitingWebhooks', () => { const executionRepository = mock(); @@ -79,4 +79,25 @@ describe('WaitingWebhooks', () => { */ await expect(promise).rejects.toThrowError(ConflictError); }); + + it('should mark as test webhook when execution mode is manual', async () => { + jest + // @ts-expect-error Protected method + .spyOn(waitingWebhooks, 'getWebhookExecutionData') + // @ts-expect-error Protected method + .mockResolvedValue(mock()); + + const execution = mock({ + finished: false, + mode: 'manual', + data: { + resultData: { lastNodeExecuted: 'someNode', error: undefined }, + }, + }); + executionRepository.findSingleExecution.mockResolvedValue(execution); + + await waitingWebhooks.executeWebhook(mock(), mock()); + + expect(execution.data.isTestWebhook).toBe(true); + }); }); diff --git a/packages/cli/src/webhooks/waiting-webhooks.ts b/packages/cli/src/webhooks/waiting-webhooks.ts index 90413b433d..4fe89180f1 100644 --- a/packages/cli/src/webhooks/waiting-webhooks.ts +++ b/packages/cli/src/webhooks/waiting-webhooks.ts @@ -121,6 +121,12 @@ export class WaitingWebhooks implements IWebhookManager { const lastNodeExecuted = execution.data.resultData.lastNodeExecuted as string; + /** + * A manual execution resumed by a webhook call needs to be marked as such + * so workers in scaling mode reuse the existing execution data. + */ + if (execution.mode === 'manual') execution.data.isTestWebhook = true; + return await this.getWebhookExecutionData({ execution, req,