(promise: Promise<T>, timeoutMs: number, message: string)
| 100 | } |
| 101 | |
| 102 | async function withTimeout<T>(promise: Promise<T>, timeoutMs: number, message: string): Promise<T> { |
| 103 | let timeout: ReturnType<typeof setTimeout> | undefined; |
| 104 | try { |
| 105 | return await Promise.race([ |
| 106 | promise, |
| 107 | new Promise<never>((_, reject) => { |
| 108 | timeout = setTimeout(() => reject(new Error(message)), timeoutMs); |
| 109 | }), |
| 110 | ]); |
| 111 | } finally { |
| 112 | if (timeout !== undefined) { |
| 113 | clearTimeout(timeout); |
| 114 | } |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | async function waitForChildExit(child: ChildProcess, timeoutMs: number): Promise<boolean> { |
| 119 | if (child.exitCode != null || child.signalCode != null) { |
no outgoing calls
no test coverage detected
searching dependent graphs…