diff --git a/packages/cli/src/commands/BaseCommand.ts b/packages/cli/src/commands/BaseCommand.ts index 2f07eb6bd3..56a82fe3e3 100644 --- a/packages/cli/src/commands/BaseCommand.ts +++ b/packages/cli/src/commands/BaseCommand.ts @@ -26,7 +26,7 @@ import { WorkflowHistoryManager } from '@/workflows/workflowHistory/workflowHist export abstract class BaseCommand extends Command { protected logger = Container.get(Logger); - protected externalHooks: IExternalHooksClass; + protected externalHooks?: IExternalHooksClass; protected nodeTypes: NodeTypes; diff --git a/packages/cli/src/commands/start.ts b/packages/cli/src/commands/start.ts index 42a5b463f5..b56fcfca90 100644 --- a/packages/cli/src/commands/start.ts +++ b/packages/cli/src/commands/start.ts @@ -101,7 +101,7 @@ export class Start extends BaseCommand { // Stop with trying to activate workflows that could not be activated this.activeWorkflowRunner.removeAllQueuedWorkflowActivations(); - await this.externalHooks.run('n8n.stop', []); + await this.externalHooks?.run('n8n.stop', []); setTimeout(async () => { // In case that something goes wrong with shutdown we diff --git a/packages/cli/src/commands/webhook.ts b/packages/cli/src/commands/webhook.ts index 12f08ab690..49bda1d53e 100644 --- a/packages/cli/src/commands/webhook.ts +++ b/packages/cli/src/commands/webhook.ts @@ -39,7 +39,7 @@ export class Webhook extends BaseCommand { this.logger.info('\nStopping n8n...'); try { - await this.externalHooks.run('n8n.stop', []); + await this.externalHooks?.run('n8n.stop', []); setTimeout(async () => { // In case that something goes wrong with shutdown we diff --git a/packages/cli/src/commands/worker.ts b/packages/cli/src/commands/worker.ts index 586a5079ea..06ae362301 100644 --- a/packages/cli/src/commands/worker.ts +++ b/packages/cli/src/commands/worker.ts @@ -79,7 +79,7 @@ export class Worker extends BaseCommand { await Worker.jobQueue.pause(true); try { - await this.externalHooks.run('n8n.stop', []); + await this.externalHooks?.run('n8n.stop', []); const maxStopTime = config.getEnv('queue.bull.gracefulShutdownTimeout') * 1000; @@ -483,7 +483,7 @@ export class Worker extends BaseCommand { }); await new Promise((resolve) => server.listen(port, () => resolve())); - await this.externalHooks.run('worker.ready'); + await this.externalHooks?.run('worker.ready'); this.logger.info(`\nn8n worker health check via, port ${port}`); }