X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fworker%2Fabstract-worker.ts;h=060fe63451877a96c0f26fe843c16ef2c7644f59;hb=896624ae5d3cb6861b202a4c3b1d4c42368868c5;hp=5c1785f2b1c92c7843fb923e6763476c8f58e080;hpb=f7abb96ebc68f7631cca52427a712e8e2c6f2bc0;p=poolifier.git 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 {