-import util from 'node:util';
-
const isUndefined = (value: unknown): boolean => {
return typeof value === 'undefined';
};
// 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);
});