* Wait for the server ready signal (when axs prints "listening on"). * The axs proxy writes the port file immediately after binding, then prints the message. * So once the signal is received, the port file should be available.
( serverId: string, timeout = 10000, )
| 197 | * So once the signal is received, the port file should be available. |
| 198 | */ |
| 199 | async function waitForServerReady( |
| 200 | serverId: string, |
| 201 | timeout = 10000, |
| 202 | ): Promise<boolean> { |
| 203 | const deadline = Date.now() + timeout; |
| 204 | const pollInterval = 50; |
| 205 | |
| 206 | while (Date.now() < deadline) { |
| 207 | if (serverReadySignals.has(serverId)) { |
| 208 | serverReadySignals.delete(serverId); |
| 209 | return true; |
| 210 | } |
| 211 | await sleep(pollInterval); |
| 212 | } |
| 213 | |
| 214 | return false; |
| 215 | } |
| 216 | |
| 217 | /** |
| 218 | * Wait for the port file to be available after server signals ready. |
no test coverage detected