Skip to content

Commit

Permalink
Merge pull request #881 from preactjs/cleanup-net-utils
Browse files Browse the repository at this point in the history
  • Loading branch information
marvinhagemeister committed Oct 6, 2021
2 parents b80f150 + f3e7006 commit 3401a9b
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions packages/wmr/src/lib/net-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,13 @@ export async function isPortFree(port) {
* @returns {Promise<number>} The next free port
*/
export async function getFreePort(port) {
let found = false;
let attempts = 0;

if (typeof port === 'string') port = parseInt(port, 10);

// Limit to 20 attempts for now
while (!found && attempts <= 20) {
if (isPortFree(port)) break;
while (attempts <= 20) {
if (await isPortFree(port)) break;

port++;
attempts++;
Expand Down

0 comments on commit 3401a9b

Please sign in to comment.