New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
2.9.1 portsAreCompatible
is a breaking change
#7545
Comments
@jeoy any chance of creating a minimal reproduction? It would be good to try to see if a fix is possible before reverting |
I don't quite understand your setup. Do you have a load balancer / proxy in front of your Vite dev server that is serving port 3000 as |
Experienced same issue after updating from 2.8.6 to 2.9.1. We run vite apps on Docker in Kubernetes and Tilt.dev. Solved it by setting port to 8080 and clientPort to 80. diff --git i/app/auth/vite.config.ts w/app/auth/vite.config.ts
index c312415b3..1b343e297 100644
--- i/app/auth/vite.config.ts
+++ w/app/auth/vite.config.ts
@@ -13,7 +13,8 @@ export default defineConfig({
},
server: {
hmr: {
- port: Number(process.env.VITE_HMR_PORT),
+ clientPort: Number(process.env.VITE_HMR_PORT),
+ port: 8080,
},
},
resolve: { |
it's quite difficult to show a minimal reproduction cause it need a domain in front of Vite dev server. I think @gudleik explain this issue clearly. At least it's a breaking change. |
portsAreCompatible
cause Critical bug!portsAreCompatible
is a breaking change
Broke me as well. I just changed hmr.port to hmr.clientPort and it is working again behind my reverse proxy setup. It seems that hmr.port now inherits from server.port, so that part is better at least. |
@benmccann If you want a reproducible test case you can have a look at the repo I created for #7562 : The fix mentioned in my reported issue works for us, btw, simply replacing Our setup looked like this:
By doing it like this the frontend did not have to know/adjust for anything Vite related: that would all be handled on the BE, which can either use a prebuilt bundle or proxy to Vite depending on a config switch. |
// svelte.config.js
// ...
vite: {
server: {
host: true,
port: 3000,
hmr: {
host: 'localhost',
protocol: 'wss',
clientPort: 443
}
}
}
// ... It's working for me now. Change 'port' to 'clientPort' It's not reloading anymore. Thank you. |
@patak-dev Is there a reason why the use-case where the It should be pretty straightforward to infer the websocket URL from
Would you be open to a PR that makes this use-case work out of the box? |
@patak-dev Digging into it a bit more, I see that was already implemented in #7463, but you reverted it in #7522 - because of a user complaint (cc @Artur-). While I think backwards compatibility should be paramount for such a popular project, I also think this was an important fix for a lot of remote development use-cases (I work at CodeSandbox, and the fact HMR in Is there anything we can do to move this further? |
Hey @lbogdan! As you mention, this is an important use case and it is a pain point for a lot of users in Vite. I agree that if possible, it should work out of the box. We're working on Vite 3 right now (a beta would be out probably in 20-30 days). So we have the opportunity to introduce breaking changes in it. If you would like to help us move this further, the best thing would be to work on a PR that reinstates #7463 (or a similar approach) but work in @Artur-'s setup or has an easy way for them to configure it when they migrate to 3.0 |
Hey @patak-dev, thanks for the quick reply, I just shared a possible approach here - sorry for being all over the place, it seems like there's a lot of related issues and PRs 🙂. |
No problem, thanks for looking into this! Sounds sensible, but I'm not used to these setups myself. I could help push it forward by involving others in the ecosystem to check a PR that would make most common cases work out of the box, and allow more esoteric setups to work by configuration. Let's take the opportunity of Vite 3 to fix this. |
Completely agree! I also think a documentation section describing how HMR works, the list of setups supported out of the box, and the required configuration for more esoteric setups might also help a lot of people. |
Describe the bug
vite/packages/vite/src/node/server/ws.ts
Line 35 in c7fc7c3
When access dev server from domain(www.mydomain.com) not localhost:xxxx, websocket always connect failed.
And It works in v2.8.6
my vite config
I highly recommended Revert this PR #7282
Reproduction
Critical bug
System Info
Used Package Manager
yarn
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: