Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function checkForPort(
port: number | undefined,
timeout: number
): Promise {
const start = Date.now();
while (!(await isPortReachable(port))) {
if (Date.now() - start > timeout) {
throw new Error(`Detecting port ${port} timed out after ${ms(timeout)}`);
}
await sleep(100);
}
}