Repository navigation
fix: support api.port 0 - #11641
Open
hi-ogawa wants to merge 8 commits into
Open
fix: support api.port 0#11641hi-ogawa wants to merge 8 commits into
hi-ogawa wants to merge 8 commits into
Conversation
Refs vitest-dev#9035 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
✅ Deploy Preview for vitest-dev ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vitest/browser
@vitest/browser-playwright
@vitest/browser-preview
@vitest/coverage-istanbul
@vitest/coverage-v8
@vitest/expect
@vitest/mocker
@vitest/pretty-format
@vitest/snapshot
@vitest/spy
@vitest/ui
@vitest/utils
vitest
@vitest/web-worker
commit: |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
hi-ogawa
commented
Oct 19, 2026
Comment on lines
+236
to
+245
| const resolvedUrls = this.ctx.vite.resolvedUrls | ||
| const origin = resolvedUrls?.local[0] ?? resolvedUrls?.network[0] | ||
| if (origin && this.ctx.config._apiRequested) { | ||
| if (this.ctx.config.ui) { | ||
| const url = new URL(this.ctx.config.uiBase, origin) | ||
| url.searchParams.set('token', this.ctx.config.api.token) | ||
| this.log(PAD + c.dim(c.green(`UI started at ${url}`))) | ||
| } else { | ||
| this.log(PAD + c.dim(c.green(`API started at ${new URL('/', origin)}`))) | ||
| } |
Collaborator
Author
There was a problem hiding this comment.
The condition is simplified to encode the intent better, which is both apiRequested exists and Vite dev server bound the url. The old fallbackUrl was for old Vite 5 era workaround, so it can be dropped vitejs/vite#15438.
hi-ogawa
marked this pull request as ready for review
October 19, 2026 09:23
This branch has not been deployed
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.
api.port: 0is conventionally expected to let the OS pick an available port, but Vitest treated0as unset and fell back to the default port (23315in browser mode,51204otherwise). This PR fixes it.Side note: Vite itself only handles
port: 0since 8.2.1 (vitejs/vite#23158), so this change relies on that fix.The new e2e test doesn't test the new behavior exactly because the behavior depends on the Vite version. Various cases are checked manually, and the setup and results are in this note: https://gist.github.com/hi-ogawa/7db0da909aee7b614e7e3ff4d11ba9a9