(f: () => Promise<T>, ms: number)
| 154 | throw Error(`Failed after ${count} tries`) |
| 155 | } |
| 156 | async function timeout<T>(f: () => Promise<T>, ms: number) { |
| 157 | return await Promise.race([ |
| 158 | f(), |
| 159 | sleep(ms).then(() => { |
| 160 | throw Error(undefined, { cause: timeoutSymbol }) |
| 161 | }), |
| 162 | ]) |
| 163 | } |
| 164 | export async function retryWithTimeout<T>( |
| 165 | f: () => Promise<T>, |
| 166 | count: number, |
no test coverage detected