From: Jérôme Benoit Date: Mon, 6 Nov 2023 12:10:28 +0000 (+0100) Subject: fix(ui): util module is not available in browser X-Git-Tag: v1.2.24~46 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=6ebeab4b8404e5a9d69b3dcdff47b9087b2058f0;p=e-mobility-charging-stations-simulator.git fix(ui): util module is not available in browser Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/Bootstrap.ts b/src/charging-station/Bootstrap.ts index 0934c1c2..baa756af 100644 --- a/src/charging-station/Bootstrap.ts +++ b/src/charging-station/Bootstrap.ts @@ -199,9 +199,9 @@ export class Bootstrap extends EventEmitter { ), new Promise((resolve) => { setTimeout(() => { - const message = `Timeout reached ${formatDurationMilliSeconds( + const message = `Timeout ${formatDurationMilliSeconds( Constants.STOP_SIMULATOR_TIMEOUT, - )} at stopping charging stations simulator`; + )} reached at stopping charging stations simulator`; console.warn(chalk.yellow(message)); resolve(message); }, Constants.STOP_SIMULATOR_TIMEOUT); diff --git a/ui/web/src/composables/Utils.ts b/ui/web/src/composables/Utils.ts index 851ba431..9e1277a8 100644 --- a/ui/web/src/composables/Utils.ts +++ b/ui/web/src/composables/Utils.ts @@ -18,10 +18,6 @@ export const ifUndefined = (value: T | undefined, isValue: T): T => { // if (isIterable(obj) === false) cb(); // }; -const isPromisePending = (promise: Promise): boolean => { - return util.inspect(promise).includes('pending'); -}; - export const promiseWithTimeout = ( promise: Promise, timeoutMs: number, @@ -33,10 +29,9 @@ export const promiseWithTimeout = ( // Create a timeout promise that rejects in timeout milliseconds const timeoutPromise = new Promise((_, reject) => { setTimeout(() => { - if (isPromisePending(promise)) { - timeoutCallback(); - // FIXME: The original promise shall be canceled - } + // FIXME: The original promise state shall be checked + timeoutCallback(); + // FIXME: The original promise shall be canceled reject(timeoutError); }, timeoutMs); });