-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
Wait for online before polling the dev server for availability in @vite/client.ts
#6791
Comments
@vite/client
wait online before polling the dev server for availability@vite/client.ts
Not sure about checking |
@patak-dev This is still an issue. The only thing that changed is the actual ping URL: it is now something like
Good point. Perhaps what I'm seeking is a configuration option with that I could control how many attempts to reconnect should the Vite client make, say per 1 sec. In order to completely disable the auto-reconnect, the option could be set to |
I think this is a duplicate of #5228. |
Clear and concise description of the problem
It is technically possible to get Vite apps to work offline in dev mode. Just configure your service worker so that it caches every request to the Vite dev server except for
__vite_ping
requests. The latter is important to prevent@vite/client
from falling into a recurring page reload: when the network connection is lost,@vite/client
pings the dev server every 1 sec and reloads the page as soon as the server responds with the HTTP 200 status.Now that you managed to run your app offline, the only problem is, you see a huge number of failed ping requests on the DevTools Network tab and in the browser console. They are quite distracting when you are testing something and are essentially unnecessary work.
Suggested solution
It would be better if
@vite/client
waited fornavigator.onLine
to becometrue
and only then started polling the dev server for availability. This way it will save unnecessary ping requests and avoid unnecessary noise in DevTools.Alternative
No response
Additional context
No response
Validations
The text was updated successfully, but these errors were encountered: