),
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);
// 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,
// 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);
});