Skip to content

Commit

Permalink
fix(ui): util module is not available in browser
Browse files Browse the repository at this point in the history
Signed-off-by: Jérôme Benoit <[email protected]>
  • Loading branch information
Jérôme Benoit committed Nov 6, 2023
1 parent 2cddfd5 commit 6ebeab4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/charging-station/Bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,9 @@ export class Bootstrap extends EventEmitter {
),
new Promise<string>((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);
Expand Down
11 changes: 3 additions & 8 deletions ui/web/src/composables/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ export const ifUndefined = <T>(value: T | undefined, isValue: T): T => {
// if (isIterable(obj) === false) cb();
// };

const isPromisePending = (promise: Promise<unknown>): boolean => {
return util.inspect(promise).includes('pending');
};

export const promiseWithTimeout = <T>(
promise: Promise<T>,
timeoutMs: number,
Expand All @@ -33,10 +29,9 @@ export const promiseWithTimeout = <T>(
// Create a timeout promise that rejects in timeout milliseconds
const timeoutPromise = new Promise<never>((_, 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);
});
Expand Down

0 comments on commit 6ebeab4

Please sign in to comment.