Skip to content

fix: use server.ws.clientPort on Vite 8.1+ - #620

Merged
ElMassimo merged 1 commit into
ElMassimo:mainfrom
iuhoay:fix/vite-8-server-ws-client-port
Aug 27, 2026
Merged

fix: use server.ws.clientPort on Vite 8.1+#620
ElMassimo merged 1 commit into
ElMassimo:mainfrom
iuhoay:fix/vite-8-server-ws-client-port

Conversation

@iuhoay

@iuhoay iuhoay commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Description 📖

vite-plugin-ruby still writes server.hmr.clientPort, which Vite 8.1 logs as deprecated on every bin/vite dev.

Closes #614.

Background 📜

rack-proxy does not forward websockets, so the plugin sets clientPort to the Vite port. Vite 8.1 moved that option to server.ws.*; Vite 8.0 still reads server.hmr.clientPort.

The Fix 🔨

Write server.ws.clientPort from Vite 8.1 onward, and keep the old assignment for Vite 5–8.0.

Screenshots 📷

Vite 8.1 deprecated server.hmr.* in favor of server.ws.*. Keep
server.hmr.clientPort on Vite 8.0 so HMR still bypasses rack-proxy.

Closes ElMassimo#614.
@ElMassimo

Copy link
Copy Markdown
Owner

Looks great, thanks!

@ElMassimo
ElMassimo merged commit 6fd5e93 into ElMassimo:main Aug 27, 2026
17 checks passed
davidrunger added a commit to davidrunger/david_runger that referenced this pull request Aug 27, 2026
Version 5.2.3 adds native Vite 8 WebSocket configuration support through
ElMassimo/vite_ruby#620, allowing
`vite.config.mjs` to call `RubyPlugin()` directly and remove the
`RubyPluginWithWebSocketConfig` transformation.

Set `skipProxy` to load development entrypoints directly from Vite. The
Vite client can then derive its WebSocket address from its own script
URL, making the explicit `server.ws.clientPort` workaround and its
config regression spec unnecessary. Permit only the local Vite HTTP and
WebSocket paths in the domain-restricted Cuprite driver so feature specs
can use the live server.

Delay `vite-plugin-full-reload` notifications by 100 ms so the Rails
evented view reloader can invalidate changed server-rendered templates
before the browser requests them. This uses the Rails-specific `delay`
option documented at
https://github.com/ElMassimo/vite-plugin-full-reload#configuration-%EF%B8%8F
and prevents the first automatic reload from rendering stale compiled
Haml.

Keep the existing Ruby dependencies unchanged. `vite_ruby` 3.10.2
already supports `vite-plugin-ruby` 5.2.x, while updating it would also
pull in `rack-proxy` 1.0 and break the Rails development proxy because
of that dependency major version change in backend policy.

Refresh and deduplicate the `pnpm` lockfile. The initial `pnpm dedupe`
was blocked by the minimum-release-age policy, so temporarily exempt
`picomatch@4.0.7` and `vite-plugin-ruby@5.2.3` through the workspace
configuration; `pnpm-update-js-packages` refreshes those exemptions on
later updates.

codex resume 01a04431-06e8-7763-89bc-f735429ac1f7
@iuhoay
iuhoay deleted the fix/vite-8-server-ws-client-port branch August 28, 2026 12:42
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 5.2.2 triggers deprecation warning under vite 8.1.5

2 participants