Commit 891f7b5a authored by Stan Hu's avatar Stan Hu

Fix Webpack manifest not working with single-threaded Web servers

The removal of the webpack-rails gem in
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/42485 changed the
way the manifest was loaded from the Webpack dev server. Instead of
contacting directly to the HTTP port 3809, the change caused an external
HTTP(s) request to be made to the GDK URL
(e.g. https://gdk.test:3001/assets/manifest.json).  This would cause a
single-threaded like Thin to lock up.

This change restores the separate `manifest_host` and `manifest_port`
that was previously used to contact the Webpack server directly.
parent c8e28190
......@@ -21,12 +21,12 @@ if app.config.public_file_server.enabled
settings = {
enabled: true,
host: dev_server.host,
manifest_host: dev_server.host,
manifest_port: dev_server.port,
port: dev_server.port
}
if Rails.env.development?
# /assets are proxied through a Rails middlware to the Webpack
# server, so we have to use the local Rails settings.
settings.merge!(
host: Gitlab.config.gitlab.host,
port: Gitlab.config.gitlab.port,
......
......@@ -88,10 +88,9 @@ module Gitlab
end
def load_dev_server_manifest
host = ::Rails.configuration.webpack.dev_server.host
port = ::Rails.configuration.webpack.dev_server.port
scheme = ::Rails.configuration.webpack.dev_server.https ? 'https' : 'http'
uri = Addressable::URI.new(scheme: scheme, host: host, port: port, path: dev_server_path)
host = ::Rails.configuration.webpack.dev_server.manifest_host
port = ::Rails.configuration.webpack.dev_server.manifest_port
uri = Addressable::URI.new(scheme: 'http', host: host, port: port, path: dev_server_path)
# localhost could be blocked via Gitlab::HTTP
response = HTTParty.get(uri.to_s, verify: false) # rubocop:disable Gitlab/HTTParty
......
......@@ -41,7 +41,9 @@ RSpec.describe Gitlab::Webpack::Manifest do
before do
# Test that config variables work while we're here
::Rails.configuration.webpack.dev_server.host = 'hostname'
::Rails.configuration.webpack.dev_server.port = 2000
::Rails.configuration.webpack.dev_server.port = 1999
::Rails.configuration.webpack.dev_server.manifest_host = 'hostname'
::Rails.configuration.webpack.dev_server.manifest_port = 2000
::Rails.configuration.webpack.manifest_filename = "my_manifest.json"
::Rails.configuration.webpack.public_path = "public_path"
::Rails.configuration.webpack.output_dir = "manifest_output"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment