Skip to content

Feature Request: Support fallback to long polling when WebSocket is unavailable for HMR #21155

@denghongcai

Description

@denghongcai

Problem

I'm using Vite for frontend development in a special sandbox environment. There's a reverse proxy between the sandbox and users that doesn't support WebSocket connections. Since Vite's HMR relies solely on WebSocket without any fallback mechanism, users cannot see code changes in real-time when WebSocket is unavailable.

Use Case

This feature would be particularly useful for:

Development environments behind reverse proxies that don't support WebSocket
Corporate networks with restrictive firewall policies
Sandboxed or containerized development environments with limited protocol support
Cloud-based IDEs or development platforms
Alternatives Considered
Currently, the only workaround is manual page refresh, which significantly degrades the development experience.

Additional Context

Similar tools like webpack-dev-server offer fallback options (sockjs) for HMR when WebSocket is unavailable. Having this capability in Vite would make it more robust in various network environments.

Suggested solution

Add support for falling back to long polling (or other HTTP-based alternatives) when WebSocket connections fail or are unavailable. This would ensure HMR functionality works in environments where WebSocket is blocked or unsupported.

Alternative

No response

Additional context

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions