(p: Promise<T>, ms: number, what: string)
| 56 | |
| 57 | // Bind a promise so a real "never arrives" bug fails the test. |
| 58 | function withTimeout<T>(p: Promise<T>, ms: number, what: string): Promise<T> { |
| 59 | let timer: ReturnType<typeof setTimeout> | undefined; |
| 60 | const timeout = new Promise<T>((_, reject) => { |
| 61 | timer = setTimeout(() => reject(new Error(`Timed out waiting for ${what} after ${ms}ms`)), ms); |
| 62 | }); |
| 63 | // Clear the timer on either resolution so Deno's leak detector is happy. |
| 64 | return Promise.race([p, timeout]).finally(() => { |
| 65 | if (timer !== undefined) clearTimeout(timer); |
| 66 | }); |
| 67 | } |
| 68 | |
| 69 | // Activation gate — split into two skip-mirrored tests so each run exercises |
| 70 | // exactly one assertion. CI on a supported Deno verifies inclusion; CI on an |
no test coverage detected