Skip to content

Commit

Permalink
Fix infinite loop when port is not available
Browse files Browse the repository at this point in the history
  • Loading branch information
marvinhagemeister committed Mar 27, 2021
1 parent 97e51f0 commit 07dbd20
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/five-hornets-admire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'wmr': patch
---

Fix potential infinite loop when searching for a free port
8 changes: 4 additions & 4 deletions packages/wmr/src/lib/net-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ export async function getFreePort(port) {

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

port++;
attempts++;
}

return port;
Expand Down

0 comments on commit 07dbd20

Please sign in to comment.