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

Check for listen port collision for browser tests #5725

Open
4 tasks done
DenizUgur opened this issue May 14, 2024 · 6 comments
Open
4 tasks done

Check for listen port collision for browser tests #5725

DenizUgur opened this issue May 14, 2024 · 6 comments
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)

Comments

@DenizUgur
Copy link

Clear and concise description of the problem

The current behavior of vitest with browser mode is that it will try to use server.port (or 5173) regardless if that port is available. If that port is occupied and serves a page (unrelated to the project) the test runner hangs.

Suggested solution

If server.port or 5173 is not available start listening on available port (similar to how vite works)

Alternative

No response

Additional context

No response

Validations

@sheremet-va
Copy link
Member

Vitest doesn't hardcode port and just calls createServer from vite. Can you provide a reproduction?

Copy link

Hello @DenizUgur. Please provide a minimal reproduction using a GitHub repository or StackBlitz (you can also use examples). Issues marked with needs reproduction will be closed if they have no activity within 3 days.

@DenizUgur
Copy link
Author

If you have existing browser test can you run the following before running the tests? If that doesn't reproduce, I'll create dedicated example.

docker run -it --rm --name nginx -p 5173:80 nginx

@sheremet-va
Copy link
Member

If you have existing browser test can you run the following before running the tests? If that doesn't reproduce, I'll create dedicated example.

docker run -it --rm --name nginx -p 5173:80 nginx

This single command requires a lot of setup to run, hardly a minimal reproduction.

@sheremet-va
Copy link
Member

Actually, I found a line where we set the default port, but it's not 5173:

@sheremet-va sheremet-va added p3-minor-bug An edge case that only affects very specific usage (priority) and removed needs reproduction labels May 14, 2024
@DenizUgur
Copy link
Author

This single command requires a lot of setup to run, hardly a minimal reproduction.

I'm sorry, I assumed docker was available to you. I can try to reproduce this outside docker if you like to but I've encountered this with only docker right now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

No branches or pull requests

2 participants