(start: number, end: number = start + 100)
| 16 | * @throws if no port in `[start, end]` is available. |
| 17 | */ |
| 18 | export async function probeFreePort(start: number, end: number = start + 100): Promise<number> { |
| 19 | for (let port = start; port <= end; port++) { |
| 20 | if (await isPortFree(port)) return port |
| 21 | } |
| 22 | throw new Error(`probeFreePort: no free port in range ${start}..${end}`) |
| 23 | } |
| 24 | |
| 25 | /** |
| 26 | * A port only counts as free when BOTH the v4 wildcard (0.0.0.0) and the |
no test coverage detected