function waitForPort(port, timeout = 60000) {
  const delay = 100;
  return new Promise((resolve) => {
    const socket = new net.Socket();
    let retries = 0;
    const connect = () => {
      socket.connect({ port });
    };
    const retry = () => {
      if (++retries > timeout / delay) {
        throw new Error(
          `Timeout while waiting for port ${port} to become available.`
        );
      }
      setTimeout(connect, delay);
    };
    socket.on("error", retry);
    socket.on("connect", () => {
      socket.destroy();
      resolve();
    });
    connect();
  });
}
/**
 * Wait for a local tcp port to become available.
 */
Wait for a local tcp port to become available.
Wait for a local tcp port to become available .
function waitForPort(port, timeout = 60000) {
  const delay = 100;
  return new Promise((resolve) => {
    const socket = new net.Socket();
    let retries = 0;
    const connect = () => {
      socket.connect({ port });
    };
    const retry = () => {
      if (++retries > timeout / delay) {
        throw new Error(
          `Timeout while waiting for port ${port} to become available.`
        );
      }
      setTimeout(connect, delay);
    };
    socket.on("error", retry);
    socket.on("connect", () => {
      socket.destroy();
      resolve();
    });
    connect();
  });
}
function waitForPort ( port , timeout = 60000 ) { const delay = 100 ; return new Promise ( ( resolve ) => { const socket = new net . Socket ( ) ; let retries = 0 ; const connect = ( ) => { socket . connect ( { port } ) ; } ; const retry = ( ) => { if ( ++ retries > timeout / delay ) { throw new Error ( ` ${ port } ` ) ; } setTimeout ( connect , delay ) ; } ; socket . on ( "error" , retry ) ; socket . on ( "connect" , ( ) => { socket . destroy ( ) ; resolve ( ) ; } ) ; connect ( ) ; } ) ; }
Wait for a local tcp port to become available.
Wait for a local tcp port to become available .