From: Jérôme Benoit Date: Sun, 19 Nov 2023 20:23:16 +0000 (+0100) Subject: refactor: cleanup task functions handling X-Git-Tag: v3.0.6~16 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=f7abb96ebc68f7631cca52427a712e8e2c6f2bc0;p=poolifier.git refactor: cleanup task functions handling Signed-off-by: Jérôme Benoit --- 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 {