fix: fix scripts permission
[e-mobility-charging-stations-simulator.git] / src / charging-station / ChargingStationWorker.ts
index db7ae2cb4462ff79f50359dc989b50536a73edd6..003d9fea96fd718f42fa356683ab0b10f231c7fb 100644 (file)
@@ -6,9 +6,10 @@ import { parentPort } from 'node:worker_threads';
 import { ThreadWorker } from 'poolifier';
 
 import { ChargingStation } from './ChargingStation';
+import { BaseError } from '../exception';
 import type { ChargingStationWorkerData } from '../types';
 import { Configuration } from '../utils';
-import { WorkerConstants, type WorkerMessage, WorkerMessageEvents } from '../worker';
+import { type WorkerMessage, WorkerMessageEvents } from '../worker';
 
 const moduleName = 'ChargingStationWorker';
 
@@ -48,7 +49,7 @@ class ChargingStationWorker extends AsyncResource {
           }
           break;
         default:
-          throw new Error(
+          throw new BaseError(
             `Unknown worker event: '${message.event}' received with data: '${JSON.stringify(
               message.data,
               null,
@@ -62,9 +63,7 @@ class ChargingStationWorker extends AsyncResource {
 
 export let chargingStationWorker: ChargingStationWorker | ThreadWorker<ChargingStationWorkerData>;
 if (Configuration.workerPoolInUse()) {
-  chargingStationWorker = new ThreadWorker<ChargingStationWorkerData>(startChargingStation, {
-    maxInactiveTime: WorkerConstants.POOL_MAX_INACTIVE_TIME,
-  });
+  chargingStationWorker = new ThreadWorker<ChargingStationWorkerData>(startChargingStation);
 } else {
   chargingStationWorker = new ChargingStationWorker();
 }