From 56f945900ccdbffb165bc42026fa20158c7032fe Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Tue, 19 Mar 2024 18:50:20 +0100 Subject: [PATCH] fix: fix worker configuration merge issue MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/charging-station/Bootstrap.ts | 4 +++- src/charging-station/ChargingStation.ts | 4 ++-- src/worker/WorkerFactory.ts | 4 +++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/charging-station/Bootstrap.ts b/src/charging-station/Bootstrap.ts index 6eacfff4..64953a96 100644 --- a/src/charging-station/Bootstrap.ts +++ b/src/charging-station/Bootstrap.ts @@ -366,7 +366,9 @@ export class Bootstrap extends EventEmitter { elementsPerWorker, poolOptions: { messageHandler: this.messageHandler.bind(this) as MessageHandler, - workerOptions: { resourceLimits: workerConfiguration.resourceLimits } + ...(workerConfiguration.resourceLimits != null && { + workerOptions: { resourceLimits: workerConfiguration.resourceLimits } + }) } } ) diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index 29aedcba..92b5fe75 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -1244,7 +1244,7 @@ export class ChargingStation extends EventEmitter { stationInfoFromFile.templateHash === stationInfoFromTemplate.templateHash ) { return setChargingStationOptions( - { ...Constants.DEFAULT_STATION_INFO, ...stationInfoFromFile }, + mergeDeepRight(Constants.DEFAULT_STATION_INFO, stationInfoFromFile), options ) } @@ -1255,7 +1255,7 @@ export class ChargingStation extends EventEmitter { stationInfoFromTemplate ) return setChargingStationOptions( - { ...Constants.DEFAULT_STATION_INFO, ...stationInfoFromTemplate }, + mergeDeepRight(Constants.DEFAULT_STATION_INFO, stationInfoFromTemplate), options ) } diff --git a/src/worker/WorkerFactory.ts b/src/worker/WorkerFactory.ts index 833c939f..67da00d8 100644 --- a/src/worker/WorkerFactory.ts +++ b/src/worker/WorkerFactory.ts @@ -1,5 +1,7 @@ import { isMainThread } from 'node:worker_threads' +import { mergeDeepRight } from 'rambda' + import type { WorkerAbstract } from './WorkerAbstract.js' import { DEFAULT_WORKER_OPTIONS } from './WorkerConstants.js' import { WorkerDynamicPool } from './WorkerDynamicPool.js' @@ -21,7 +23,7 @@ export class WorkerFactory { if (!isMainThread) { throw new Error('Cannot get a worker implementation outside the main thread') } - workerOptions = { ...DEFAULT_WORKER_OPTIONS, ...workerOptions } + workerOptions = mergeDeepRight(DEFAULT_WORKER_OPTIONS, workerOptions ?? {}) let workerImplementation: WorkerAbstract switch (workerProcessType) { case WorkerProcessType.workerSet: -- 2.34.1