From bd49917b865689795b8d69a49b9ef954902cf95b Mon Sep 17 00:00:00 2001 From: elrrrrrrr Date: Thu, 11 Jul 2024 21:26:52 +0800 Subject: [PATCH] fix: ignore hook when disable (#702) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit > Currently, `triggerHookWorkerMaxConcurrentTasks` is 10 by defualt, which can lead to some redis queries even hookEnable is not activated. * ♻️ Follow `CreateTriggerHookWorker`, when hookEnable is not activated, do not query task queue. ------- > 目前 triggerHookWorkerMaxConcurrentTasks 默认为 10,在未开启 hookEnable 时会带来一些冗余的 redis 查询 * ♻️ 参照 `CreateTriggerHookWorker` 逻辑,hookEnable 关闭时,不进行存量任务轮训 ## Summary by CodeRabbit - **Bug Fixes** - Added a check to ensure hooks are enabled before proceeding, improving reliability and preventing errors when hooks are disabled. --- app/port/schedule/TriggerHookWorker.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/app/port/schedule/TriggerHookWorker.ts b/app/port/schedule/TriggerHookWorker.ts index 2e594c4f..8b4f2623 100644 --- a/app/port/schedule/TriggerHookWorker.ts +++ b/app/port/schedule/TriggerHookWorker.ts @@ -27,6 +27,7 @@ export class TriggerHookWorker { private readonly taskService: TaskService; async subscribe() { + if (!this.config.cnpmcore.hookEnable) return; if (executingCount >= this.config.cnpmcore.triggerHookWorkerMaxConcurrentTasks) return; executingCount++;