Fix Rspack/Webpack HMR port when http-router is enabled

What does this merge request do and why?

When gitlab_http_router is enabled (the default), config.nginx.__listen_address resolves to nginx's internal listen port (e.g. gdk.test:8080) rather than the browser-facing port owned by the router (e.g. gdk.test:3443). The Rspack and Webpack __dev_server_public settings built the HMR WebSocket URL from that internal address, so the browser tried to connect to the wrong port and Rspack's overlay escalated the failed socket into a fatal, page-blocking error.

This MR makes __dev_server_public router-aware in both components/rspack/GDK.rb and components/webpack/GDK.rb, mirroring the pattern already used by components/nginx/GDK.rb (__port) and the earlier Vite HMR fixes (!4262 (merged), !4289 (merged)):

  • Router enabled: use config.hostname:config.port (the browser-facing address).
  • Router disabled, nginx enabled: keep the existing config.nginx.__listen_address behaviour.

Specs in spec/lib/gdk/config_spec.rb are extended to cover both router states, with and without HTTPS, for both bundlers. The previous specs only asserted against nginx.__listen_address under the default (router-enabled) config, which encoded the bug.

Fixes #3365 (closed)

How to set up and validate locally

  1. Ensure gitlab_http_router is enabled (default), nginx is enabled with https and port: 3443, and Rspack is the bundler (default).
  2. Check out this branch, then gdk reconfigure && gdk restart.
  3. Open the app in a browser: no Rspack overlay error, and the HMR WebSocket connects to wss://gdk.test:3443/_hmr/ (not :8080).
  4. Optionally verify with gdk config get rspack.__dev_server_public (and webpack.__dev_server_public with webpack enabled).
  5. Disable the router (gdk config set gitlab_http_router.enabled false && gdk reconfigure) and confirm the value falls back to the nginx listen address.

Test run: bundle exec rspec spec/lib/gdk/config_spec.rb passes; bundle exec rubocop --config .rubocop-gdk.yml reports no offenses on the changed files.

Impacted categories

The following categories relate to this merge request:

Merge request checklist

  • This MR references an issue describing the change.
  • This change is backward compatible. If not, include steps to communicate to users.
  • Tests added for new functionality. If not, raise an issue to follow-up.
  • Observability added/updated (logging, metrics, tracing).
  • Documentation added/updated.
  • Announcement added for notable changes.
  • gdk doctor test added.

Merge request reports

Loading
Loading