mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
fix(core): Fix resuming executions on test webhooks from Wait nodes (#13168)
This commit is contained in:
@@ -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);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
Reference in New Issue
Block a user