fix: remove worker task usage at task function removal
[poolifier.git] / src / worker / abstract-worker.ts
index 8bbd07a713c2a30c7f4614012350de54ed69bf55..6c6de861156e040285fc3a4ad4c50ba5e796f04f 100644 (file)
@@ -396,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)
+        }
+      })
     })
   }
 
@@ -607,7 +611,7 @@ export abstract class AbstractWorker<
           taskPerformance,
           taskId
         })
-        return null
+        return undefined
       })
       .catch(error => {
         this.sendToMainWorker({