(promise: Promise<T>, ms: number, label: string)
| 18 | } |
| 19 | |
| 20 | async function withTimeout<T>(promise: Promise<T>, ms: number, label: string): Promise<T> { |
| 21 | let timer: NodeJS.Timeout | undefined; |
| 22 | try { |
| 23 | return await Promise.race([ |
| 24 | promise, |
| 25 | new Promise<T>((_, reject) => { |
| 26 | timer = setTimeout(() => reject(new Error(`Timeout: ${label}`)), ms); |
| 27 | }), |
| 28 | ]); |
| 29 | } finally { |
| 30 | if (timer) clearTimeout(timer); |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | it("should return last session id after sending a message", async () => { |
| 35 | const session = await client.createSession({ onPermissionRequest: approveAll }); |
no outgoing calls
no test coverage detected
searching dependent graphs…