-
Notifications
You must be signed in to change notification settings - Fork 12k
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
Conversation
packages/angular_devkit/build_angular/src/angular-cli-files/utilities/check-port.ts
Outdated
Show resolved
Hide resolved
ac85b59
to
faafbd9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks
There was a problem hiding this 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.
There was a problem hiding this 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.
good catch @clydin. |
Make senses. But why someone will pass the port as zero @clydin ? In this way of thinking, |
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. |
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. |
faafbd9
to
8e65aef
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. See above.
packages/angular_devkit/build_angular/src/angular-cli-files/utilities/check-port.ts
Outdated
Show resolved
Hide resolved
packages/angular_devkit/build_angular/src/angular-cli-files/utilities/check-port.ts
Outdated
Show resolved
Hide resolved
packages/angular_devkit/build_angular/src/angular-cli-files/utilities/check-port.ts
Outdated
Show resolved
Hide resolved
@alan-agius4 I change the checkPort observable to a promise. Now that I have refactored the code, do you think this can close issue 8595? |
@tiaguinho, yeah this should solve #8595 |
packages/angular_devkit/build_angular/src/angular-cli-files/utilities/check-port.ts
Outdated
Show resolved
Hide resolved
packages/angular_devkit/build_angular/src/angular-cli-files/utilities/check-port.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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.
packages/angular_devkit/build_angular/src/angular-cli-files/utilities/check-port.ts
Outdated
Show resolved
Hide resolved
97ed73f
to
85d3afc
Compare
packages/angular_devkit/build_angular/src/angular-cli-files/utilities/check-port.ts
Outdated
Show resolved
Hide resolved
packages/angular_devkit/build_angular/src/angular-cli-files/utilities/check-port.ts
Outdated
Show resolved
Hide resolved
85d3afc
to
cad1245
Compare
cad1245
to
840908a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, LGTM
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
@hansl I have checked the usage of
checkPort
function, and the parambasePort
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?