Skip to content

fix(server): use a random port when port is 0 - #23158

Merged
sapphi-red merged 9 commits into
vitejs:mainfrom
BlankParticle:feature/fix/track-assigned-server-port
Aug 6, 2026
Merged

sapphi-red merged 9 commits into
vitejs:mainfrom
BlankParticle:feature/fix/track-assigned-server-port

Conversation

@BlankParticle

Copy link
Copy Markdown
Contributor

fixes this #7529 bug again
I recently had a use case for assigning server.port = 0 and read back the assigned port for use
but looks like doing that would cause it trigger !configPort and vite would use the default port
fixed by making it explicitly typeof configPort !== 'number'

TheAlexLichter
TheAlexLichter previously approved these changes Aug 4, 2026
Comment thread packages/vite/src/node/http.ts Resolved
@sapphi-red sapphi-red added feat: dev dev server p2-edge-case Bug, but has workaround or limited in scope (priority) labels Aug 5, 2026
Comment thread packages/vite/src/node/http.ts Resolved
sapphi-red
sapphi-red previously approved these changes Aug 6, 2026

ghost left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

ghost left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(noticed a small refactor)

@sapphi-red
sapphi-red merged commit fddf4ea into vitejs:main Aug 6, 2026
@BlankParticle
BlankParticle deleted the feature/fix/track-assigned-server-port branch August 6, 2026 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat: dev dev server p2-edge-case Bug, but has workaround or limited in scope (priority)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants