fix(core): Throw error when workflow is too big for webhook registration (#21860)

This commit is contained in:
yehorkardash
2025-12-09 10:47:25 +01:00
committed by GitHub
parent 07e84c9d63
commit fd08baf141
3 changed files with 32 additions and 1 deletions
+5
View File
@@ -87,6 +87,11 @@ export class CacheService extends TypedEmitter<CacheEvents> {
return this.cache.kind === 'memory';
}
async exists(key: string) {
const ttl = await this.cache?.store.ttl(key);
return !!ttl;
}
// ----------------------------------
// storing
// ----------------------------------
@@ -20,6 +20,11 @@ describe('TestWebhookRegistrationsService', () => {
const webhookKey = 'GET|hello';
const cacheKey = 'test-webhooks';
beforeEach(() => {
jest.resetAllMocks();
cacheService.exists.mockResolvedValue(true);
});
describe('register()', () => {
test('should register a test webhook registration', async () => {
await registrations.register(registration);
@@ -32,6 +37,14 @@ describe('TestWebhookRegistrationsService', () => {
expect(cacheService.expire).not.toHaveBeenCalled();
});
test('should throw an error if the registration fails', async () => {
cacheService.exists.mockResolvedValue(false);
await expect(registrations.register(registration)).rejects.toThrow(
'Test webhook registration failed: workflow is too big. Remove pinned data',
);
});
});
describe('deregister()', () => {
@@ -1,6 +1,11 @@
import { Service } from '@n8n/di';
import { InstanceSettings } from 'n8n-core';
import type { IWebhookData, IWorkflowBase, IDestinationNode } from 'n8n-workflow';
import {
type IWebhookData,
type IWorkflowBase,
type IDestinationNode,
UserError,
} from 'n8n-workflow';
import { TEST_WEBHOOK_TIMEOUT, TEST_WEBHOOK_TIMEOUT_BUFFER } from '@/constants';
import { CacheService } from '@/services/cache/cache.service';
@@ -44,6 +49,14 @@ export class TestWebhookRegistrationsService {
await this.cacheService.setHash(this.cacheKey, { [hashKey]: registration });
const isCached = await this.cacheService.exists(this.cacheKey);
if (!isCached) {
throw new UserError(
'Test webhook registration failed: workflow is too big. Remove pinned data',
);
}
if (this.instanceSettings.isSingleMain) return;
/**