fix(core): Fix resuming executions on test webhooks from Wait nodes (#13168)

This commit is contained in:
Iván Ovejero 2025-02-10 16:43:54 +01:00 committed by GitHub
parent 8f25a06e6c
commit 5dddf772cf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 28 additions and 1 deletions

View file

@ -6,7 +6,7 @@ import { ConflictError } from '@/errors/response-errors/conflict.error';
import { NotFoundError } from '@/errors/response-errors/not-found.error'; import { NotFoundError } from '@/errors/response-errors/not-found.error';
import type { IExecutionResponse } from '@/interfaces'; import type { IExecutionResponse } from '@/interfaces';
import { WaitingWebhooks } from '@/webhooks/waiting-webhooks'; import { WaitingWebhooks } from '@/webhooks/waiting-webhooks';
import type { WaitingWebhookRequest } from '@/webhooks/webhook.types'; import type { IWebhookResponseCallbackData, WaitingWebhookRequest } from '@/webhooks/webhook.types';
describe('WaitingWebhooks', () => { describe('WaitingWebhooks', () => {
const executionRepository = mock<ExecutionRepository>(); const executionRepository = mock<ExecutionRepository>();
@ -79,4 +79,25 @@ describe('WaitingWebhooks', () => {
*/ */
await expect(promise).rejects.toThrowError(ConflictError); 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<IWebhookResponseCallbackData>());
const execution = mock<IExecutionResponse>({
finished: false,
mode: 'manual',
data: {
resultData: { lastNodeExecuted: 'someNode', error: undefined },
},
});
executionRepository.findSingleExecution.mockResolvedValue(execution);
await waitingWebhooks.executeWebhook(mock<WaitingWebhookRequest>(), mock<express.Response>());
expect(execution.data.isTestWebhook).toBe(true);
});
}); });

View file

@ -121,6 +121,12 @@ export class WaitingWebhooks implements IWebhookManager {
const lastNodeExecuted = execution.data.resultData.lastNodeExecuted as string; 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({ return await this.getWebhookExecutionData({
execution, execution,
req, req,