(promise: Promise<T>, operation: string)
| 698 | } |
| 699 | |
| 700 | async function within<T>(promise: Promise<T>, operation: string): Promise<T> { |
| 701 | let timeout: NodeJS.Timeout | undefined; |
| 702 | try { |
| 703 | return await Promise.race([ |
| 704 | promise, |
| 705 | new Promise<T>((_resolve, reject) => { |
| 706 | timeout = setTimeout(() => reject(new Error(`${operation} timed out`)), 1_000); |
| 707 | }), |
| 708 | ]); |
| 709 | } finally { |
| 710 | if (timeout) clearTimeout(timeout); |
| 711 | } |
| 712 | } |
no test coverage detected