vitest-dev / vitest-dev/vitest

Pick lower ephemeral port for browser mode

Open
#9,035 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement: pending triage
Dominant language
TypeScript
Stars
17.1k
Forks
2k
Avg merge
1d 22h
Merged PRs (30d)
94

Description

Clear and concise description of the problem

When using browser mode, Vitest picks a port starting at 63315.
I've been observing failures with some users using "corporate" windows devices. I wasn't able to diagnose in detail but it seems that some security policies might prevent users from starting servers on high ranges.

IANA seems to recommend the following range 49152-65535 for ephemeral ports, hence the 63315, I guess.

Right now, I don't know if the whole range is blocked by such policies and if it would be more pragmatic to just use a port range <10000.

I am opening this issue to collect more feedback from the trenches.

Suggested solution

Pick ports in a lower range.

Alternative

The current workaround is to override the port manually in the configuration:

{
  test: {
    browser: {
      api: 7357
    }
  }
}
Additional context

No response

Validations

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files or tests are named. Start by locating the browser mode port selection and its configuration handling, then investigate a lower default range and the existing manual override. Done means browser mode uses a lower default port while explicit values such as 7357 continue to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
testing-qa
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.