From c0aa28c6cf3f77b04e04663217c9df8e3803ed3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Ovejero?= Date: Mon, 14 Oct 2024 16:12:41 +0200 Subject: [PATCH] fix(core): Override executions mode if `regular` during worker startup (#11250) --- packages/cli/src/commands/worker.ts | 4 ++++ packages/cli/test/integration/commands/worker.cmd.test.ts | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/packages/cli/src/commands/worker.ts b/packages/cli/src/commands/worker.ts index 1685fbb034..c86cf0936f 100644 --- a/packages/cli/src/commands/worker.ts +++ b/packages/cli/src/commands/worker.ts @@ -61,6 +61,10 @@ export class Worker extends BaseCommand { constructor(argv: string[], cmdConfig: Config) { if (!process.env.N8N_ENCRYPTION_KEY) throw new WorkerMissingEncryptionKey(); + if (config.getEnv('executions.mode') !== 'queue') { + config.set('executions.mode', 'queue'); + } + super(argv, cmdConfig); this.logger = Container.get(Logger).withScope('scaling'); diff --git a/packages/cli/test/integration/commands/worker.cmd.test.ts b/packages/cli/test/integration/commands/worker.cmd.test.ts index 2326ed595a..1840a9b170 100644 --- a/packages/cli/test/integration/commands/worker.cmd.test.ts +++ b/packages/cli/test/integration/commands/worker.cmd.test.ts @@ -39,6 +39,8 @@ mockInstance(Push); const command = setupTestCommand(Worker); test('worker initializes all its components', async () => { + config.set('executions.mode', 'regular'); // should be overridden + const worker = await command.run(); expect(worker.queueModeId).toBeDefined(); expect(worker.queueModeId).toContain('worker'); @@ -53,4 +55,6 @@ test('worker initializes all its components', async () => { expect(logStreamingEventRelay.init).toHaveBeenCalledTimes(1); expect(orchestrationWorkerService.init).toHaveBeenCalledTimes(1); expect(messageEventBus.send).toHaveBeenCalledTimes(1); + + expect(config.getEnv('executions.mode')).toBe('queue'); });