feat: allow to disable tasks timeout check in worker
[poolifier.git] / src / worker / abstract-worker.ts
index 176a5893caeeec7cb9d82095840b97498b3822b0..2afd6f3486a1103347a258c575cece7773e3c4d3 100644 (file)
@@ -71,7 +71,10 @@ export abstract class AbstractWorker<
     super(type)
     this.checkWorkerOptions(this.opts)
     this.checkTaskFunctions(taskFunctions)
-    if (!this.isMain) {
+    if (
+      !this.isMain &&
+      (this.opts.maxInactiveTime ?? DEFAULT_MAX_INACTIVE_TIME) > 0
+    ) {
       this.lastTaskTimestamp = performance.now()
       this.aliveInterval = setInterval(
         this.checkAlive.bind(this),
@@ -266,7 +269,7 @@ export abstract class AbstractWorker<
     name = name ?? DEFAULT_FUNCTION_NAME
     const fn = this.taskFunctions.get(name)
     if (fn == null) {
-      throw new Error(`Task function "${name}" not found`)
+      throw new Error(`Task function '${name}' not found`)
     }
     return fn
   }