On Click calling _ember_jquery at wrong path

I’ve been debugging an issue I’m having with BS4 dropdowns not working and found that on click, _ember_jquery.js is being called at /assets/var/www/discourse/public/assets instead of at /assets (which is where it is actually located). Not sure why the full server path is being appended. To my knowledge, no relevant config changes have been made, and the only thing I’ve been working on is adding a simple, custom plugin (yes, the problem persists even with the plugin removed). I’m fairly new to Discourse, so any thoughts on the matter would be greatly appreciated. Please let me know if you need any additional info.

I believe this is a problem with the way the source map is being generated, caused by this PR: https://github.com/discourse/discourse/pull/7834.

Previously, the -p relative option was used so source map paths looked like [‘admin…js.map’]. Starting with 2.4.beta9, the -p option is not available because of the change to uglify 3, so source map paths were absolute like [’/var/www/discourse/public/assets/admin…js.map’]. This caused the source maps to 404 when debugging since the actual file was at /assets, but the map indicated it was at /var/www/…/assets.

A workaround I found was to change lib/tasks/asset.rake to add the base option to the source map parameter so it looks like this:

  base = assets_path + ((d = File.dirname(from)) == "." ? "" : "/#{d}")

  cmd = <<~EOS
    uglifyjs '#{assets_path}/#{from}' -m -c -o '#{to_path}' --source-map "base='#{base}',root='#{source_map_root}',url='#{source_map_url}'" --output '#{to_path}'

I can’t guarantee it would work for everyone, but it allows me to debug via source maps without the 404 errors.


Did we need to fix this @sam?

Yeah we are tracking this elsewhere, will add a note on the TODO so @Roman_Rizzi is aware.


Sorry for the delay, the issue is now fixed and backported to beta and stable. I added the base attribute, which contains the path to the asset, leaving the source attribute with only the filename.