refactor: check for worker file existence first
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Wed, 20 Sep 2023 20:17:00 +0000 (22:17 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Wed, 20 Sep 2023 20:17:00 +0000 (22:17 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
src/pools/abstract-pool.ts
tests/pools/abstract-pool.test.js

index e525cc9a5ccd1ac9b3e58bbc5d867e4f82ea2603..70459dbbee743d82f158eb9739e9bda8367478e4 100644 (file)
@@ -133,8 +133,8 @@ export abstract class AbstractPool<
         'Cannot start a pool from a worker with the same type as the pool'
       )
     }
-    this.checkNumberOfWorkers(this.numberOfWorkers)
     checkFilePath(this.filePath)
+    this.checkNumberOfWorkers(this.numberOfWorkers)
     this.checkPoolOptions(this.opts)
 
     this.chooseWorkerNode = this.chooseWorkerNode.bind(this)
index 3860a0eb95fc4f50de2ea9ff28813860faafd9b6..85d48d6a4e4eecaab910c20814a8abc471cc6fe3 100644 (file)
@@ -79,7 +79,13 @@ describe('Abstract pool test suite', () => {
   })
 
   it('Verify that numberOfWorkers is checked', () => {
-    expect(() => new FixedThreadPool()).toThrowError(
+    expect(
+      () =>
+        new FixedThreadPool(
+          undefined,
+          './tests/worker-files/thread/testWorker.js'
+        )
+    ).toThrowError(
       new Error(
         'Cannot instantiate a pool without specifying the number of workers'
       )