From f7abb96ebc68f7631cca52427a712e8e2c6f2bc0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sun, 19 Nov 2023 21:23:16 +0100 Subject: [PATCH] refactor: cleanup task functions handling MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/worker/abstract-worker.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/worker/abstract-worker.ts b/src/worker/abstract-worker.ts index 43135467..5c1785f2 100644 --- a/src/worker/abstract-worker.ts +++ b/src/worker/abstract-worker.ts @@ -493,8 +493,7 @@ export abstract class AbstractWorker< */ protected run (task: Task): void { const { name, taskId, data } = task - const fn = this.taskFunctions.get(name ?? DEFAULT_TASK_NAME) - if (fn == null) { + if (!this.taskFunctions.has(name ?? DEFAULT_TASK_NAME)) { this.sendToMainWorker({ workerError: { name: name as string, @@ -505,6 +504,7 @@ export abstract class AbstractWorker< }) return } + const fn = this.taskFunctions.get(name ?? DEFAULT_TASK_NAME) if (isAsyncFunction(fn)) { this.runInAsyncScope(this.runAsync.bind(this), this, fn, task) } else { -- 2.34.1