From 6ebeab4b8404e5a9d69b3dcdff47b9087b2058f0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Mon, 6 Nov 2023 13:10:28 +0100 Subject: [PATCH] fix(ui): util module is not available in browser 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 ++-- ui/web/src/composables/Utils.ts | 11 +++-------- 2 files changed, 5 insertions(+), 10 deletions(-) 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); }); -- 2.34.1