]> Piment Noir Git Repositories - poolifier.git/commitdiff
fix(benchmarks): destroy pool in the error case
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Tue, 2 Dec 2025 13:26:48 +0000 (14:26 +0100)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Tue, 2 Dec 2025 13:26:48 +0000 (14:26 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
benchmarks/benchmarks-utils.mjs

index 83013e6760ea3ac5394634c4caf285d26303ae46..4cf11681732ae48f67c88b15444f869a508b71bf 100644 (file)
@@ -66,9 +66,10 @@ export const runPoolifierBenchmarkTinyBench = async (
   { taskExecutions, workerData }
 ) => {
   const bmfResults = {}
+  let pool
   try {
     const bench = new Bench()
-    const pool = buildPoolifierPool(workerType, poolType, poolSize)
+    pool = buildPoolifierPool(workerType, poolType, poolSize)
 
     for (const workerChoiceStrategy of Object.values(WorkerChoiceStrategies)) {
       for (const enableTasksQueue of [false, true]) {
@@ -136,7 +137,6 @@ export const runPoolifierBenchmarkTinyBench = async (
 
     const tasks = await bench.run()
     console.table(bench.table())
-    await pool.destroy()
 
     for (const task of tasks) {
       if (
@@ -163,6 +163,10 @@ export const runPoolifierBenchmarkTinyBench = async (
   } catch (error) {
     console.error(error)
     return bmfResults
+  } finally {
+    if (pool != null) {
+      await pool.destroy()
+    }
   }
 }