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

server.hmr = false should disable server ping #8020

Closed
7 tasks done
jcushman opened this issue May 4, 2022 · 5 comments
Closed
7 tasks done

server.hmr = false should disable server ping #8020

jcushman opened this issue May 4, 2022 · 5 comments

Comments

@jcushman
Copy link

jcushman commented May 4, 2022

Describe the bug

When HMR is disabled with server.hmr = false, client.ts still opens a websocket to the server, and then runs await fetch(`${base}__vite_ping`) once per second if the socket is closed.

This is a problem in backend integration settings (e.g. Django) because the default value for ${base} points to the backend server rather than the vite server, and there is no way to configure the value with hmr disabled.

This means if the socket is closed, Vite ends up pinging the backend server until refresh, with no way to configure what url is being pinged. This ends up polluting the backend dev server log with continual 404s and interfering with development.

There are some previous related bugs about disabling HMR and/or server ping: #1729 #1989 #5228 #5763. I'm filing this one separately to document the issue that server.hmr = false ends up pinging an unrelated server in backend integrations and can't be configured. Having server.hmr = false disable ping seems like a promising fix.

Reproduction

na

System Info

na

Used Package Manager

npm

Logs

No response

Validations

@sapphi-red
Copy link
Member

Is this a duplicate of #2345?

@jcushman
Copy link
Author

jcushman commented May 5, 2022

I missed that one! It's not quite a dupe, but it would help: the fix for that bug (proposed in the #6819 PR) would still leave vite pinging an unconfigurable hmr url with server.hmr = false, but it would ping the vite server instead of the backend server, so not cause as much of a problem.

This bug strikes me as still valid in principle: if the way to disable hmr is server.hmr = false, then setting that should disable things like hmr pings that are configured by server.hmr.server, server.hmr.port etc. Disabling hmr is mutually incompatible with configuring hmr in vite's config language, so it should turn off things configured under server.hmr, or there should be another way to disable hmr.

I'm not sure there's another bug that exactly covers this, but there's a bunch of bugs all in this general cluster, so I'm fine with closing this if it's easier to track elsewhere.

@sapphi-red
Copy link
Member

Do you want to disable pings to vite server? If so, why do you want to do that?
I don't think there is a situation which someone needs to disable pings to vite server.

@masterkain
Copy link

#8133

@sapphi-red
Copy link
Member

Closing as the original issue is solved by #6819.

@github-actions github-actions bot locked and limited conversation to collaborators May 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants