Skip to content
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

HMR is not completely disabled #13994

Closed
7 tasks done
MarryDream opened this issue Jul 31, 2023 · 3 comments
Closed
7 tasks done

HMR is not completely disabled #13994

MarryDream opened this issue Jul 31, 2023 · 3 comments
Labels
enhancement: pending triage wontfix This will not be worked on

Comments

@MarryDream
Copy link

Describe the bug

For some specific reason, I had to start the project using Vite in the production environment. At this point, I set config.server.hmr to false in an attempt to avoid unnecessary overhead in the production environment. However, I found that when set to false, the page still creates websocket requests and sends ping messages periodically. However, when the server firewall does not open the default port 24678, the Websocket fails to connect, which triggers a shutdown event and causes the page to auto-refresh over and over again. The Websocket connection seemed useless when config.server.hmr was set to false, so I made some changes to avoid creating a Websocket connection in this case.

Reproduction

https://github.com/MarryDream/vite-hmr-demo

Steps to reproduce

npm i
npm start

Please deploy to a production server for testing,allow port 11451 on the firewall and access http://ip:11451. But do not allow port 24678

System Info

System:
    OS: Linux 3.10 CentOS Linux 7 (Core)
    CPU: (2) x64 Intel(R) Xeon(R) Gold 6133 CPU @ 2.50GHz
    Memory: 2.83 GB / 7.64 GB
    Container: Yes
    Shell: 4.2.46 - /bin/bash
  Binaries:
    Node: 16.14.0 - /opt/node/v16.14.0/bin/node
    npm: 8.3.1 - /opt/node/v16.14.0/bin/npm
    pnpm: 8.6.10 - /opt/node/v16.14.0/bin/pnpm
  npmPackages:
    @vitejs/plugin-vue: ^4.2.3 => 4.2.3 
    vite: ^4.4.7 => 4.4.7

Used Package Manager

npm

Logs

No response

Validations

@sapphi-red
Copy link
Member

The websocket is used for more than just HMR, including showing error overlay from server and trigger full page reloads from plugins.
#6315 (comment)

So Vite shouldn't disable websocket even if config.server.hmr: false is set.

Maybe you can transform the @vite/client by the transform hook?

@sapphi-red sapphi-red added wontfix This will not be worked on enhancement: pending triage and removed pending triage labels Jul 31, 2023
@MarryDream
Copy link
Author

The websocket is used for more than just HMR, including showing error overlay from server and trigger full page reloads from plugins.
#6315 (comment)

So Vite shouldn't disable websocket even if config.server.hmr: false is set.

Maybe you can transform the @vite/client by the transform hook?

I'm very sorry, I didn't notice that this issue had already been mentioned, after looking at #9007 ,I tried to work around it by customizing hmr.server, which seems to be working so far.

@sapphi-red
Copy link
Member

I'll close this issue then 👍

@github-actions github-actions bot locked and limited conversation to collaborators Aug 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement: pending triage wontfix This will not be worked on
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants