( promise: Promise<T>, timeoutMs: number, message: string, )
| 230 | } |
| 231 | |
| 232 | function timeoutPromise<T>( |
| 233 | promise: Promise<T>, |
| 234 | timeoutMs: number, |
| 235 | message: string, |
| 236 | ): Promise<T> { |
| 237 | let timer: NodeJS.Timeout | undefined |
| 238 | const timeout = new Promise<never>((_, reject) => { |
| 239 | timer = setTimeout(() => reject(new Error(message)), timeoutMs) |
| 240 | }) |
| 241 | return Promise.race([promise, timeout]).finally(() => { |
| 242 | if (timer) { |
| 243 | clearTimeout(timer) |
| 244 | } |
| 245 | }) |
| 246 | } |
| 247 | |
| 248 | export class RemoteAppServerClient { |
| 249 | private ws: WS | null = null |
no outgoing calls
no test coverage detected