Skip to content

Studio: Refactor windows port checker to use portFinder helpers - #1281

Merged
gavande1 merged 10 commits into
trunkfrom
stu-103-refactor-windows-port-check
Apr 28, 2025
Merged

Studio: Refactor windows port checker to use portFinder helpers#1281
gavande1 merged 10 commits into
trunkfrom
stu-103-refactor-windows-port-check

Conversation

@gavande1

@gavande1 gavande1 commented Apr 27, 2025

Copy link
Copy Markdown
Contributor

Related issues

Note

We also have checkPortInWindows in src/lib/proxy-server.ts. There's an obvious difference in that the checkPortInWindows function only runs on Windows, but I still wonder if we shouldn't refactor that function and PortFinder::isPortFree to share the same underlying logic.

Proposed Changes

  • Refactor Windows port checker to use portFinder helpers

Testing Instructions

  1. Check out the branch on a Windows machine.
  2. Open a new terminal tab and run:
    php -S localhost:80
  3. In another terminal tab, start Studio by running:
    npm start
  4. Confirm that you receive an alert indicating the port is busy (similar to the screenshots provided).

CleanShot 2025-04-27 at 18 44 30@2x

CleanShot 2025-04-27 at 18 46 30@2x

  1. Stop Studio (Ctrl+C in the terminal).
  2. Cancel the PHP server process (Ctrl+C in the other terminal).
  3. Wait a few seconds to ensure both processes have fully stopped.
  4. Start Studio again by running:
    npm start
  5. Confirm that this time, you do not receive any alert about the port being busy.

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?

@fredrikekelund fredrikekelund left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Elegant and works as expected 👍

Not directly related to this PR, but I noticed this error message:

Studio needs to use port 80 and 443 to enable custom domains and SSL, but one of both of these ports are already in use by another app. Close any local development apps and restart Studio.

I would remove "of both" from that message to make it sound more idiomatic. I.e., it would read:

Studio needs to use port 80 and 443 to enable custom domains and SSL, but one of these ports are already in use by another app. Close any local development apps and restart Studio.

Comment thread src/lib/proxy-server.ts Outdated

@bcotrim bcotrim left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@gavande1
gavande1 force-pushed the stu-103-refactor-windows-port-check branch from 69f3cad to a0f509d Compare April 28, 2025 09:16
@gavande1
gavande1 requested a review from fredrikekelund April 28, 2025 09:16

@fredrikekelund fredrikekelund left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with two nits 👍

Comment thread src/lib/proxy-server.ts Outdated
Comment thread src/lib/proxy-server.ts Outdated
gavande1 and others added 2 commits April 28, 2025 15:26
Co-authored-by: Fredrik Rombach Ekelund <fredrik@f26d.dev>
Co-authored-by: Fredrik Rombach Ekelund <fredrik@f26d.dev>
@gavande1
gavande1 merged commit 6b797e6 into trunk Apr 28, 2025
@gavande1
gavande1 deleted the stu-103-refactor-windows-port-check branch April 28, 2025 12:49
@gavande1 gavande1 self-assigned this May 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants