(promise: Promise<T>, ms: number, label: string)
| 36 | }); |
| 37 | |
| 38 | async function withTimeout<T>(promise: Promise<T>, ms: number, label: string): Promise<T> { |
| 39 | let timer: ReturnType<typeof setTimeout> | undefined; |
| 40 | try { |
| 41 | return await Promise.race([ |
| 42 | promise, |
| 43 | new Promise<T>((_, reject) => { |
| 44 | timer = setTimeout(() => reject(new Error(`Timeout: ${label}`)), ms); |
| 45 | }), |
| 46 | ]); |
| 47 | } finally { |
| 48 | if (timer) clearTimeout(timer); |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | function waitForEvent( |
| 53 | session: { on: (handler: (event: SessionEvent) => void) => () => void }, |
no outgoing calls
no test coverage detected
searching dependent graphs…