fix: fix worker options argument passing to worker pool/set
[e-mobility-charging-stations-simulator.git] / src / charging-station / ui-server / UIHttpServer.ts
index 9e33302682533c68d39e9536cc878bd15a3b68c6..159559df1f4cacb6eebaa1f67b8e6cca66ac030a 100644 (file)
@@ -2,6 +2,8 @@ import type { IncomingMessage, RequestListener, ServerResponse } from 'node:http
 
 import { StatusCodes } from 'http-status-codes';
 
+import { AbstractUIServer } from './AbstractUIServer';
+import { UIServerUtils } from './UIServerUtils';
 import { BaseError } from '../../exception';
 import {
   type ProcedureName,
@@ -14,7 +16,6 @@ import {
   type UIServerConfiguration,
 } from '../../types';
 import { Constants, Utils, logger } from '../../utils';
-import { AbstractUIServer, UIServerUtils } from '../internal';
 
 const moduleName = 'UIHttpServer';
 
@@ -43,7 +44,7 @@ export class UIHttpServer extends AbstractUIServer {
   public sendResponse(response: ProtocolResponse): void {
     const [uuid, payload] = response;
     try {
-      if (this.responseHandlers.has(uuid) === true) {
+      if (this.hasResponseHandler(uuid) === true) {
         const res = this.responseHandlers.get(uuid) as ServerResponse;
         res
           .writeHead(this.responseStatusToStatusCode(payload.status), {
@@ -124,6 +125,11 @@ export class UIHttpServer extends AbstractUIServer {
                   body ?? Constants.EMPTY_FREEZED_OBJECT
                 )
               )
+              .then((protocolResponse: ProtocolResponse) => {
+                if (!Utils.isNullOrUndefined(protocolResponse)) {
+                  this.sendResponse(protocolResponse);
+                }
+              })
               .catch(Constants.EMPTY_FUNCTION);
           });
       } else {