export const promiseWithTimeout = <T>(
  promise: Promise<T>,
  timeoutMs: number,
  fallbackValue: T | undefined = undefined
) => {
  return Promise.race([
    promise,
    new Promise<T | undefined>((resolve) =>
      setTimeout(() => resolve(fallbackValue), timeoutMs)
    ),
  ])
}
