Skip to content

refactor(@angular-devkit/build-angular): improve check port #13292

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

Merged
merged 1 commit into from
Jan 8, 2019

Conversation

tiaguinho
Copy link
Contributor

@hansl I have checked the usage of checkPort function, and the param basePort was never passed.
I also read the code of portfinder and saw that, when we set the port option, basePort will not be used.
Instead of that, I think set the highestPort to the same as the port we are looking for can improve the time to check if the port is opened.

What do you think?

Copy link
Collaborator

@alan-agius4 alan-agius4 left a comment

Choose a reason for hiding this comment

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

LGTM, thanks

Copy link
Collaborator

@alan-agius4 alan-agius4 left a comment

Choose a reason for hiding this comment

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

Ps: I think you need to remove Close 8595 from your commit message. As this doesn't fix anything per see.

Copy link
Member

@clydin clydin left a comment

Choose a reason for hiding this comment

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

Base port is used when zero is passed as the port. This shouldn’t be removed as it changes existing behavior.

@alan-agius4
Copy link
Collaborator

good catch @clydin.

@tiaguinho
Copy link
Contributor Author

Make senses. But why someone will pass the port as zero @clydin ?

In this way of thinking, basePort is used as a parameter, which also can be passed as zero.
Will not make more sense remove this as a parameter and set the value directly to portfinder.basePort?

@alan-agius4
Copy link
Collaborator

alan-agius4 commented Dec 24, 2018

Port 0 is a wildcard port, which tells the system to find a suitable available port.

This can be useful in CI’s, re the baseport, I am actually not sure why we don’t use the default. But while setting the base port is 0 is possible, it doesn’t make any sense to do so, and would probably result in an exception from port finder.

@clydin, would know more, re why not use the default.

@clydin
Copy link
Member

clydin commented Dec 24, 2018

The package really isn’t needed at all. If you are interested in a refactor, you could completely remove its usage.

If the supplied port is not zero, try to bind to the port and host. If it fails, throw the error. If it works, pass on the port.

@tiaguinho tiaguinho changed the title refactor(@angular-devkit/build-angular): check port refactor(@angular-devkit/build-angular): improve check port Dec 24, 2018
Copy link
Collaborator

@alan-agius4 alan-agius4 left a comment

Choose a reason for hiding this comment

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

Thanks. See above.

@tiaguinho
Copy link
Contributor Author

@alan-agius4 I change the checkPort observable to a promise.
All my changes are in separate commits, but if you want I can squash all into one.

Now that I have refactored the code, do you think this can close issue 8595?

@alan-agius4
Copy link
Collaborator

@tiaguinho, yeah this should solve #8595

Copy link
Contributor

@hansl hansl left a comment

Choose a reason for hiding this comment

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

One possible recursion. Otherwise looks good to me.

Copy link
Collaborator

@alan-agius4 alan-agius4 left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM

@alan-agius4 alan-agius4 added the target: major This PR is targeted for the next major release label Dec 27, 2018
@alexeagle alexeagle merged commit b233e8f into angular:master Jan 8, 2019
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
target: major This PR is targeted for the next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants