mirror of
https://github.com/n8n-io/n8n.git
synced 2025-02-21 02:56:40 -08:00
fix(core): Fix resuming executions on test webhooks from Wait nodes (#13168)
This commit is contained in:
parent
8f25a06e6c
commit
5dddf772cf
|
@ -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<ExecutionRepository>();
|
||||
|
@ -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<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;
|
||||
|
||||
/**
|
||||
* 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,
|
||||
|
|
Loading…
Reference in a new issue