fix: dynamic pool options change
authorJérôme Benoit <jerome.benoit@sap.com>
Tue, 6 Jun 2023 18:35:21 +0000 (20:35 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Tue, 6 Jun 2023 18:35:21 +0000 (20:35 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/pools/abstract-pool.ts

index ce645cc87af3c9638cf418cb300af4ea18c2dcca..b86a3b13a6b538efb4024c0ebe8e49df22e4a1a8 100644 (file)
@@ -342,7 +342,7 @@ export abstract class AbstractPool<
       this.checkValidTasksQueueOptions(tasksQueueOptions)
       this.opts.tasksQueueOptions =
         this.buildTasksQueueOptions(tasksQueueOptions)
-    } else {
+    } else if (this.opts.tasksQueueOptions != null) {
       delete this.opts.tasksQueueOptions
     }
   }
@@ -625,11 +625,11 @@ export abstract class AbstractPool<
         this.emitter.emit(PoolEvents.error, error)
       }
     })
-    if (this.opts.restartWorkerOnError === true) {
-      worker.on('error', () => {
+    worker.on('error', () => {
+      if (this.opts.restartWorkerOnError === true) {
         this.createAndSetupWorker()
-      })
-    }
+      }
+    })
     worker.on('online', this.opts.onlineHandler ?? EMPTY_FUNCTION)
     worker.on('exit', this.opts.exitHandler ?? EMPTY_FUNCTION)
     worker.once('exit', () => {