From: Jérôme Benoit Date: Wed, 22 Nov 2023 08:50:43 +0000 (+0100) Subject: refactor: cleanup task function default name handling X-Git-Tag: v3.0.6~9 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=c878a2403fcb0672b7d7be4ca6cd5dd96b47bd3a;p=poolifier.git refactor: cleanup task function default name handling Signed-off-by: Jérôme Benoit --- 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 {