(
promise: Promise<T>,
timeoutMs: number,
message: string
)
| 41 | } |
| 42 | |
| 43 | async function withTimeout<T>( |
| 44 | promise: Promise<T>, |
| 45 | timeoutMs: number, |
| 46 | message: string |
| 47 | ): Promise<T> { |
| 48 | let timeout: ReturnType<typeof setTimeout> | undefined; |
| 49 | try { |
| 50 | return await Promise.race([ |
| 51 | promise, |
| 52 | new Promise<never>((_, reject) => { |
| 53 | timeout = setTimeout(() => reject(new Error(message)), timeoutMs); |
| 54 | }), |
| 55 | ]); |
| 56 | } finally { |
| 57 | if (timeout) { |
| 58 | clearTimeout(timeout); |
| 59 | } |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | function tryDeleteFile(filePath: string): void { |
| 64 | try { |
no outgoing calls
no test coverage detected
searching dependent graphs…