build: disable esModuleInterop from TS configuration
authorJérôme Benoit <jerome.benoit@sap.com>
Tue, 4 Jul 2023 21:02:09 +0000 (23:02 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Tue, 4 Jul 2023 21:02:09 +0000 (23:02 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
CHANGELOG.md
src/pools/abstract-pool.ts
src/pools/pool.ts
src/pools/worker.ts
src/utils.ts
tsconfig.json

index 6e05c369fcd5a8efa7fc42cd0dd0992d649c0df4..596b7f4d063d5ccb4aea6f63f8c9062719643051 100644 (file)
@@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 
 ## [Unreleased]
 
+### Fixed
+
+- Recreate the right worker type on uncaught exception.
+
+### Added
+
+- Add minimum and maximum to internal measurement statistics.
+
 ## [2.6.8] - 2023-07-03
 
 ### Fixed
index bfd0268aebff7a880c59a1bb77ec67603a16e3f7..95df53b2861293c72e2ef6c1e00fa4a4fc5f2c21 100644 (file)
@@ -1,4 +1,4 @@
-import crypto from 'node:crypto'
+import { randomUUID } from 'node:crypto'
 import { performance } from 'node:perf_hooks'
 import type { MessageValue, PromiseResponseWrapper } from '../utility-types'
 import {
@@ -469,7 +469,7 @@ export abstract class AbstractPool<
       // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
       data: data ?? ({} as Data),
       timestamp,
-      id: crypto.randomUUID()
+      id: randomUUID()
     }
     const res = new Promise<Response>((resolve, reject) => {
       this.promiseResponseMap.set(submittedTask.id as string, {
@@ -938,10 +938,10 @@ export abstract class AbstractPool<
   private checkAndEmitEvents (): void {
     if (this.emitter != null) {
       if (this.busy) {
-        this.emitter?.emit(PoolEvents.busy, this.info)
+        this.emitter.emit(PoolEvents.busy, this.info)
       }
       if (this.type === PoolTypes.dynamic && this.full) {
-        this.emitter?.emit(PoolEvents.full, this.info)
+        this.emitter.emit(PoolEvents.full, this.info)
       }
     }
   }
index 22757f9a54a841597d0394c51675efa25ac08a5d..bb28535b0e732c7eafee9fa353f38166999862e5 100644 (file)
@@ -1,4 +1,4 @@
-import EventEmitterAsyncResource from 'node:events'
+import { EventEmitter } from 'node:events'
 import type {
   ErrorHandler,
   ExitHandler,
@@ -47,7 +47,7 @@ export type WorkerType = keyof typeof WorkerTypes
 /**
  * Pool events emitter.
  */
-export class PoolEmitter extends EventEmitterAsyncResource {}
+export class PoolEmitter extends EventEmitter {}
 
 /**
  * Enumeration of pool events.
index 20fac7ccce33fe1b32ac16874b1d721758cef137..35853b7dcf427b8281d65b74399106707b930577 100644 (file)
@@ -144,10 +144,6 @@ export interface WorkerInfo {
    * Started flag.
    */
   started: boolean
-  /**
-   * Shared buffer.
-   */
-  readonly sharedBuffer?: Int32Array
 }
 
 /**
index f3952ab1746f559e780774b61520e099d7cdc310..80e6b9f3b5473dee9e5547930f05ce8b6b473631 100644 (file)
@@ -1,4 +1,4 @@
-import os from 'node:os'
+import { cpus, availableParallelism as parallelism } from 'node:os'
 import type {
   MeasurementStatisticsRequirements,
   WorkerChoiceStrategyOptions
@@ -41,11 +41,11 @@ export const DEFAULT_MEASUREMENT_STATISTICS_REQUIREMENTS: MeasurementStatisticsR
 export const availableParallelism = (): number => {
   let availableParallelism = 1
   try {
-    availableParallelism = os.availableParallelism()
+    availableParallelism = parallelism()
   } catch {
-    const cpus = os.cpus()
-    if (Array.isArray(cpus) && cpus.length > 0) {
-      availableParallelism = cpus.length
+    const numberOfCpus = cpus()
+    if (Array.isArray(numberOfCpus) && numberOfCpus.length > 0) {
+      availableParallelism = numberOfCpus.length
     }
   }
   return availableParallelism
index c2c97a3613d255f62ba9449978ae6abb8e87ffc5..ce2bf2c6e1c14a82285b93b8b86f91cad6829830 100644 (file)
@@ -5,7 +5,6 @@
     "module": "ES2022",
     "outDir": "lib",
     "moduleResolution": "Node",
-    "esModuleInterop": true,
     "declaration": true,
     "strict": true,
     "forceConsistentCasingInFileNames": true