Skip to content

fix: restore hmr client port on Vite 8.1+ - #637

Merged
ElMassimo merged 1 commit into
mainfrom
max/fix-hmr-client-port
Oct 16, 2026
Merged

ElMassimo merged 1 commit into
mainfrom
max/fix-hmr-client-port

Conversation

@ElMassimo

Copy link
Copy Markdown
Owner

GitHub Issue #636

Description 📖

This pull request restores HMR on Vite 8.1+ when vite dev passes an inline server configuration.

Closes #636.

Background 📜

Vite 8.1 exposes the deprecated server.hmr transport options through compatibility getters. The wrapper owns clientPort even when no value was configured.

An inline server: {} causes Vite to install that wrapper before the plugin's config hook runs. The property-ownership check then treats the unset port as a user override, so the browser tries to connect to the Rails port instead of the Vite port.

The existing tests called the configuration loader directly, bypassing Vite's config merge.

The Fix 🔨

Using the configured values to distinguish an unset port from an explicit override. Explicit ports, including 0, remain untouched, as do disabled HMR and WebSocket transports.

Vite's hmr compatibility getter owns clientPort even when it is unset. Check the value instead so inline server config does not suppress the default websocket port.

Closes #636.
@ElMassimo
ElMassimo merged commit 7054636 into main Oct 16, 2026
10 checks passed
@ElMassimo
ElMassimo deleted the max/fix-hmr-client-port branch October 16, 2026 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

vite-plugin-ruby skips clientPort on Vite 8.1+ when vite dev passes an inline server config

1 participant