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_addressbehaviour.
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
- Ensure
gitlab_http_routeris enabled (default), nginx is enabled with https andport: 3443, and Rspack is the bundler (default). - Check out this branch, then
gdk reconfigure && gdk restart. - Open the app in a browser: no Rspack overlay error, and the HMR WebSocket connects to
wss://gdk.test:3443/_hmr/(not:8080). - Optionally verify with
gdk config get rspack.__dev_server_public(andwebpack.__dev_server_publicwith webpack enabled). - 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:
- gdk-reliability - e.g. When a GDK action fails to complete.
- gdk-usability - e.g. Improvements or suggestions around how the GDK functions.
- gdk-performance - e.g. When a GDK action is slow or times out.
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 doctortest added.