Function
waitExecutionFor
(
func: () => Promise<void>,
timeout: number,
)
Source from the content-addressed store, hash-verified
| 413 | } |
| 414 | |
| 415 | export async function waitExecutionFor( |
| 416 | func: () => Promise<void>, |
| 417 | timeout: number, |
| 418 | ) { |
| 419 | const start = Date.now(); |
| 420 | while (Date.now() - start < 10000) { |
| 421 | try { |
| 422 | await func(); |
| 423 | return; |
| 424 | } catch { |
| 425 | await new Promise(resolve => setTimeout(resolve, 100)); // wait and retry |
| 426 | } |
| 427 | } |
| 428 | |
| 429 | throw new Error(`Timeout of ${timeout} reached.`); |
| 430 | } |
Tested by
no test coverage detected