( child: Server, timeoutMs: number, )
| 48 | } |
| 49 | |
| 50 | async function waitForExit( |
| 51 | child: Server, |
| 52 | timeoutMs: number, |
| 53 | ): Promise<{ |
| 54 | code: number | null; |
| 55 | signal: NodeJS.Signals | null; |
| 56 | elapsedMs: number; |
| 57 | }> { |
| 58 | const start = Date.now(); |
| 59 | return await new Promise((resolve, reject) => { |
| 60 | const timer = setTimeout(() => { |
| 61 | child.kill('SIGKILL'); |
| 62 | reject(new Error(`server did not exit within ${timeoutMs}ms`)); |
| 63 | }, timeoutMs); |
| 64 | child.once('exit', (code, signal) => { |
| 65 | clearTimeout(timer); |
| 66 | resolve({code, signal, elapsedMs: Date.now() - start}); |
| 67 | }); |
| 68 | }); |
| 69 | } |
| 70 | |
| 71 | async function rpc( |
| 72 | child: Server, |
no test coverage detected