Repository navigation
test: let the OS choose the vitest browser fixture's server port - #838
Merged
Merged
Conversation
fspy benchmarklinuxmacoswindows |
Vitest browser mode listens on the fixed port 63315 by default. On Windows runners that port can fall inside an excluded port range, where listening fails with EACCES and Vitest does not fall back to another port. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
wan9chi
force-pushed
the
claude/dazzling-cartwright-4d060c
branch
from
October 12, 2026 05:25
410f406 to
0db9d70
Compare
fengmk2
added a commit
to voidzero-dev/vite-plus
that referenced
this pull request
Oct 12, 2026
The browser snapshots use Vitest's fixed API port, which Windows can reserve. This causes intermittent `EACCES` failures. Set `test.api.port` to `0` in a post-configuration hook, after Vitest resolves its defaults. The OS selects an available port when the server binds. This follows [vite-task#838](voidzero-dev/vite-task#838) and preserves the snapshot assertions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
vitest_browser_cache::vitest_browser_caches_inputs_and_restores_outputsfails intermittently on Windows runners in theTest (windows-ignored)job:63315 is the fixed default port for Vitest browser mode's server. Windows reserves dynamic port ranges (Hyper-V/WinNAT excluded port ranges), and listening on a reserved port fails with
EACCES. Vite only tries another port onEADDRINUSE, so the run fails,dist/result.jsonis never written, and the snapshot diverges. It depends on which runner the job lands on: it failed on #824 and #825 and passed on other runs of the same code.Changes
The fixture's browser server now listens on port 0, so the OS chooses a free port. Vite supports
server.listen(0)directly, but the config can't request it the normal way:test.api: { port: 0 }: Vitest only copiesapi.portwhen it is truthy, so0falls back to 63315.test.apiat all, even with a concrete port, adds anAPI started at http://localhost:<port>/banner line that would change the snapshot.test.browser.apiprints a deprecation warning in Vitest 5.Instead, a small
enforce: 'post'plugin setstest.api.port = 0after Vitest resolvestest.api. The banner stays unchanged, and the snapshot is identical.🤖 Generated with Claude Code