[feat] Use dynamic port if specified port is already in use#2441
[feat] Use dynamic port if specified port is already in use#2441baseballyama wants to merge 2 commits into
Conversation
🦋 Changeset detectedLatest commit: 76950f2 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
I'd want this to be run by Rich first, because IIRC he had opinions about apps automatically picking different ports rather than noisily failing and forcing you to say what port you wanted to use. I also don't know anything about this dependency you're adding, and adding dependencies is something that should always be looked at very carefully. I see that |
|
We should be able to easily craft our own port finding logic too with the current |
|
Thank you for telling the background.
Agree with you. and sorry for that. |
|
This functionality is already available in Vite with the I think a better solution to this problem would be to merge #2232, so that the Vite server options take effect, which would remove a lot of confusion that people have about those options not doing anything today |
This is related to #948
Summary of the PR
At least on Windows, when I execute
npm run devlike the above issue's reproduction steps, I got the below error if 3000 port is already in use.I think this is correct behavior.
But on the other hand, webpack-dev-server has the feature that dev server finds free port if a default port is already in use.
https://github.com/webpack/webpack-dev-server/pull/685/files
So I implemented almost the same feature.
If a user specifies a specific port, dev server will check only the port.
But if not, dev server searches usable port from 3000.
Questions
Thank you!!
Before submitting the PR, please make sure you do the following
Tests
pnpm testand lint the project withpnpm lintandpnpm checkChangesets
pnpx changesetand following the prompts. All changesets should bepatchuntil SvelteKit 1.0