From aa4bf4b27479408af59e1cd36b98fe0c22bc7f03 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sun, 9 Jul 2023 02:02:05 +0200 Subject: [PATCH] fix: workaround import issue with `node:os` module in node 16.x.x MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- CHANGELOG.md | 4 ++++ src/utils.ts | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1696e716..e2d00ee4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed + +- Workaround import issue with `node:os` module in node 16.x.x. + ## [2.6.11] - 2023-07-09 ### Fixed diff --git a/src/utils.ts b/src/utils.ts index 80e6b9f3..128b65da 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,4 +1,4 @@ -import { cpus, availableParallelism as parallelism } from 'node:os' +import * as os from 'node:os' import type { MeasurementStatisticsRequirements, WorkerChoiceStrategyOptions @@ -41,9 +41,9 @@ export const DEFAULT_MEASUREMENT_STATISTICS_REQUIREMENTS: MeasurementStatisticsR export const availableParallelism = (): number => { let availableParallelism = 1 try { - availableParallelism = parallelism() + availableParallelism = os.availableParallelism() } catch { - const numberOfCpus = cpus() + const numberOfCpus = os.cpus() if (Array.isArray(numberOfCpus) && numberOfCpus.length > 0) { availableParallelism = numberOfCpus.length } -- 2.34.1