From: Jérôme Benoit Date: Sun, 31 Mar 2024 20:12:00 +0000 (+0200) Subject: fix(benchmark): remove timeouting in benchmark.js X-Git-Tag: v3.1.28~5 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=6aec0be366216d2bf76eafb51cbf1c05521e9df8;p=poolifier.git fix(benchmark): remove timeouting in benchmark.js Signed-off-by: Jérôme Benoit --- diff --git a/benchmarks/benchmarks-utils.mjs b/benchmarks/benchmarks-utils.mjs index 0cd3a172..0971e683 100644 --- a/benchmarks/benchmarks-utils.mjs +++ b/benchmarks/benchmarks-utils.mjs @@ -83,34 +83,30 @@ export const runPoolifierBenchmarkBenchmarkJs = async ( { taskExecutions, workerData } ) => { return await new Promise((resolve, reject) => { - let pool = buildPoolifierPool(workerType, poolType, poolSize) + const pool = buildPoolifierPool(workerType, poolType, poolSize) try { const suite = new Benchmark.Suite(name, { onComplete: () => { - const destroyTimeout = setTimeout(() => { - console.error('Pool destroy timeout reached (30s)') + if (pool.started && !pool.destroying) { + pool.destroy().then(resolve).catch(reject) + } else { resolve() - pool = undefined - }, 30000) - pool - .destroy() - .then(resolve) - .catch(reject) - .finally(() => { - clearTimeout(destroyTimeout) - }) - .catch(() => {}) + } }, onCycle: event => { console.info(event.target.toString()) }, onError: event => { - pool - .destroy() - .then(() => { - return reject(event.target.error) - }) - .catch(() => {}) + if (pool.started && !pool.destroying) { + pool + .destroy() + .then(() => { + return reject(event.target.error) + }) + .catch(() => {}) + } else { + reject(event.target.error) + } } }) for (const workerChoiceStrategy of Object.values(