fix: test task function name only if the received from workers
[poolifier.git] / src / pools / abstract-pool.ts
index 5b2bd15012142fa7e075fa8ea4968041ccfdd63a..d36e8a4737dbe5514aa936de561780baee5ba528 100644 (file)
@@ -670,9 +670,13 @@ export abstract class AbstractPool<
         typeof name === 'string' &&
         name.trim().length === 0
       ) {
-        reject(new Error('name argument must not be an empty string'))
+        reject(new TypeError('name argument must not be an empty string'))
       }
-      if (name != null && !this.taskFunctions.includes(name)) {
+      if (
+        name != null &&
+        this.taskFunctions != null &&
+        !this.taskFunctions.includes(name)
+      ) {
         reject(
           new Error(`Task function '${name}' is not registered in the pool`)
         )