Skip to content

Wait for online before polling the dev server for availability in @vite/client.ts #6791

@vursen

Description

@vursen

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 for navigator.onLine to become true 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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions