refactor: use pool side task functions list for hasTaskFunction()
[poolifier.git] / src / pools / abstract-pool.ts
index 90cede3a8227f7e21cd7a0f32ec84e4f8e6bdbf6..1b53065c54e18318f1295bd68e6340dc5cbc76c1 100644 (file)
@@ -737,11 +737,15 @@ export abstract class AbstractPool<
 
   /** @inheritDoc */
   public hasTaskFunction (name: string): boolean {
-    this.sendToWorkers({
-      taskFunctionOperation: 'has',
-      taskFunctionName: name
-    })
-    return true
+    for (const workerNode of this.workerNodes) {
+      if (
+        Array.isArray(workerNode.info.taskFunctionNames) &&
+        workerNode.info.taskFunctionNames.includes(name)
+      ) {
+        return true
+      }
+    }
+    return false
   }
 
   /** @inheritDoc */