You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Improve reliability of the Turbopack HMR WebSocket connection, especially in unstable network environments.
Allow detection of broken or stale connections caused by proxies, VPNs, or sleep mode.
Enable clients to reconnect or reload when a connection is no longer valid.
Non-Goals
Make this a default option (could be opt-in via config for now).
Replace existing HMR mechanisms or protocols.
Introduce a full WebSocket management layer.
Background
Note: This feature is particularly relevant when running a remote development environment.
Turbopack's HMR currently relies on a persistent WebSocket connection. However, in practice, these connections can silently break due to proxies, VPNs, or other network conditions. Without a keep-alive mechanism (such as ping/pong), the client may not detect the disconnection, resulting in a stale development session where HMR silently stops working.
Other development tools—such as Vite, Parcel, and Webpack Dev Server—use periodic heartbeat messages to monitor connection health and automatically trigger reconnections when needed.
Proposal
Introduce an optional ping/pong heartbeat in Turbopack’s HMR server and client. This would involve:
The client sending a ping every N seconds.
The server responding with a pong.
If the client doesn't receive a pong in a timeout window, it assumes the connection is broken and attempts to reconnect or reload the page.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Goals
Non-Goals
Background
Turbopack's HMR currently relies on a persistent WebSocket connection. However, in practice, these connections can silently break due to proxies, VPNs, or other network conditions. Without a keep-alive mechanism (such as ping/pong), the client may not detect the disconnection, resulting in a stale development session where HMR silently stops working.
Other development tools—such as Vite, Parcel, and Webpack Dev Server—use periodic heartbeat messages to monitor connection health and automatically trigger reconnections when needed.
Proposal
Introduce an optional ping/pong heartbeat in Turbopack’s HMR server and client. This would involve:
If the client doesn't receive a pong in a timeout window, it assumes the connection is broken and attempts to reconnect or reload the page.
Beta Was this translation helpful? Give feedback.
All reactions