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

We should use a more rigorous logic to resolve the port of the dev server and the ‘printServerUrls’ function #7271

Closed
4 tasks done
libmw opened this issue Mar 11, 2022 · 7 comments

Comments

@libmw
Copy link

libmw commented Mar 11, 2022

Clear and concise description of the problem

As a developer using Vite I want optimize the resolve logic of develop server port and the server running at... log.So that user can visit thier dev server correctlly.
I intend to submit a PR for this issue.

Vite is able to find another port when the candidate port is used by other program,but it's not rigorous sometimes.

Incorrect localhost

image

Vite will show unreachable ip

  • When the compute have more than one network interface,vite will show all of then,even the ip is unreachable:
    image

Suggested solution

I don't know if the above questions are bugs or rules,but I still try to optimize them.

For port conflicts I try to optimize by

  1. If option host is undefined or :: or 0.0.0.0, user mostly want to visit thier server by every address.I would check all local address to see if they are used by option port.

  2. If option host is 127.0.0.1 or localhost,user mostly want to visit thier server by localhost.I would check 127.0.0.1 and ::1 and :: with option port to make sure that users can use localhost to access thier server.

  3. For other host I only chek the specific option host and user can only visit thier server by it.

  4. For each of the conflict port, I'll show whitch host it used by.

image

For printServerUrls I use these logic

For ipv6 networkInterface address:

  1. If the address is equal to the opiton host and the option host is not ::,this address will be used as the host name.ie: http://[::1]:3000/
  2. Otherwise this address will not be displayed

For ipv4 networkInterface address:

  1. If the address is equal to the opiton host , or opiton host is undefined or 0.0.0.0 or :: ,this address will be used as the host name..ie: http://192.0.0.1:3000/
  2. If the address is 127.0.0.1 and the option host is not ::1 ,this address will be displayd as the resolved host name. ie: http://localhost:3000/
  3. Otherwise this address will not be displayed

Alternative

No response

Additional context

I am working on a PR for implementing this feature.

Validations

@sapphi-red
Copy link
Member

Maybe the first one is duplicate of #5241, #7075 ?

@libmw
Copy link
Author

libmw commented Mar 11, 2022

Maybe the first one is duplicate of #5241, #7075 ?

Yes Yes. I think vite is really not rigorous enough in the server.host configuration and printServerUrls function, I think my above rules should be more reasonable.
Here's some test case:
image
image
image
image
image
image

@libmw
Copy link
Author

libmw commented May 19, 2022

It's been two months and vite still hasn't fixed the problem,so sad 👎

@bluwy
Copy link
Member

bluwy commented May 23, 2022

I intend to submit a PR for this issue.

PR welcome.

@libmw
Copy link
Author

libmw commented May 27, 2022

so why my pr #7274 can not be merged?thanks.

@sapphi-red
Copy link
Member

@libmw Your PR is not passing tests. Would you fix it?

@sapphi-red
Copy link
Member

I believe this is fixed by #8543, #8634, #8647. If there is still any improvements please create a new issue or pr. Thank you.

@sapphi-red sapphi-red closed this as not planned Won't fix, can't repro, duplicate, stale Jul 1, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Jul 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants