From c878a2403fcb0672b7d7be4ca6cd5dd96b47bd3a Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Wed, 22 Nov 2023 09:50:43 +0100 Subject: [PATCH] refactor: cleanup task function default name 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 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/worker/abstract-worker.ts b/src/worker/abstract-worker.ts index 5c1785f2..060fe634 100644 --- a/src/worker/abstract-worker.ts +++ b/src/worker/abstract-worker.ts @@ -493,7 +493,8 @@ export abstract class AbstractWorker< */ protected run (task: Task): void { const { name, taskId, data } = task - if (!this.taskFunctions.has(name ?? DEFAULT_TASK_NAME)) { + const taskFunctionName = name ?? DEFAULT_TASK_NAME + if (!this.taskFunctions.has(taskFunctionName)) { this.sendToMainWorker({ workerError: { name: name as string, @@ -504,7 +505,7 @@ export abstract class AbstractWorker< }) return } - const fn = this.taskFunctions.get(name ?? DEFAULT_TASK_NAME) + const fn = this.taskFunctions.get(taskFunctionName) if (isAsyncFunction(fn)) { this.runInAsyncScope(this.runAsync.bind(this), this, fn, task) } else { -- 2.34.1