X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fworker%2Fabstract-worker.ts;h=6c6de861156e040285fc3a4ad4c50ba5e796f04f;hb=adee605399485348ae224e7e4c022f024373b0ef;hp=bc62ade55ef15efac79c8c9e8835a45cb697aa40;hpb=08416934cb21e9dca8281c9e7121d3863cc742bf;p=poolifier.git diff --git a/src/worker/abstract-worker.ts b/src/worker/abstract-worker.ts index bc62ade5..6c6de861 100644 --- a/src/worker/abstract-worker.ts +++ b/src/worker/abstract-worker.ts @@ -326,6 +326,7 @@ export abstract class AbstractWorker< DEFAULT_TASK_NAME, this.taskFunctions.get(name) as TaskFunction ) + this.sendTaskFunctionNamesToMainWorker() return { status: true } } catch (error) { return { status: false, error: error as Error } @@ -376,7 +377,7 @@ export abstract class AbstractWorker< protected handleTaskFunctionOperationMessage ( message: MessageValue ): void { - const { taskFunctionOperation, taskFunction, taskFunctionName } = message + const { taskFunctionOperation, taskFunctionName, taskFunction } = message let response!: TaskFunctionOperationReturnType if (taskFunctionOperation === 'add') { response = this.addTaskFunction( @@ -395,10 +396,14 @@ export abstract class AbstractWorker< this.sendToMainWorker({ taskFunctionOperation, taskFunctionOperationStatus: response.status, - workerError: { - name: taskFunctionName as string, - message: this.handleError(response.error as Error | string) - } + taskFunctionName, + ...(!response.status && + response?.error != null && { + workerError: { + name: taskFunctionName as string, + message: this.handleError(response.error as Error | string) + } + }) }) } @@ -606,7 +611,7 @@ export abstract class AbstractWorker< taskPerformance, taskId }) - return null + return undefined }) .catch(error => { this.sendToMainWorker({