Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(angular): automatically set next remote port #9422

Merged
merged 1 commit into from Mar 21, 2022

Conversation

Coly010
Copy link
Contributor

@Coly010 Coly010 commented Mar 21, 2022

Current Behavior

We expect people to pass a port for their remote apps. However, we default to 4200 if they do not. This can cause conflicts when a host app has multiple remotes on the same port.

Expected Behavior

Instead of defaulting to 4200, scan the ports used in the workspace and pick a port that is 1 greater than the highest value.

We should not run into issues with reserved ports as the current range of ports is open for use.

In development, the user shouldn't need to care where their remotes are being served if they are being accessed via host.
Also, the serve command on a remote app will specify the URL of the served app.

@Coly010 Coly010 self-assigned this Mar 21, 2022
@nx-cloud
Copy link

nx-cloud bot commented Mar 21, 2022

☁️ Nx Cloud Report

CI ran the following commands for commit a309639. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch


✅ Successfully ran 8 targets

Sent with 💌 from NxCloud.

@vercel
Copy link

vercel bot commented Mar 21, 2022

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/nrwl/nx-dev/An3iQnv1p4M5DpBiV6uPGVXRgkHN
✅ Preview: Canceled

[Deployment for a309639 canceled]

Copy link
Member

@leosvelperez leosvelperez left a comment

Choose a reason for hiding this comment

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

LGTM! 🎉

ports.add(port);
}

const nextAvailablePort = [...ports].sort((a, b) => b - a)[0] + 1;
Copy link
Member

Choose a reason for hiding this comment

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

nit: we could improve readability a bit by doing:

Suggested change
const nextAvailablePort = [...ports].sort((a, b) => b - a)[0] + 1;
const nextAvailablePort = Math.max(...ports) + 1;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I like that a lot!

@Coly010 Coly010 merged commit 47697c6 into nrwl:master Mar 21, 2022
@Coly010 Coly010 deleted the angular/auto-find-new-port branch March 21, 2022 11:18
@github-actions
Copy link

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants