magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.39k stars 9.29k forks source link

JS Minification issue & requirejs loading in production mode in 2.4.7 #38829

Closed KrzysztofWisniewskiAcc closed 1 week ago

KrzysztofWisniewskiAcc commented 1 month ago

Preconditions and environment

  1. Magento community/commerce version: 2.4.7
  2. Firefox browser (I was able to reproduce this on other browsers, but in firefox, the issue occurs almost all the time)

Steps to reproduce

1) Install fresh Magento version of 2.4.7 2) Enable js minification (there are few ways to do it, I edit the config.php/env.php file) ...

'system' => [
        'default' => [
            'dev' => [
                'template' => [
                    'minify_html' => '1'
                ],
                'js' => [
                    'merge_files' => '0',
                    'minify_files' => '1',
                    'enable_js_bundling' => '0'
                ],
                'css' => [
                    'minify_files' => '1'
                ],
                'grid' => [
                    'async_indexing' => '1'
                ]
            ],
        ]
    ]

3) Run:

bin/magento setup:upgrade
bin/magento deploy:mode:set production

4) Now go to front and open the console, errors should be there 5) If errors are not there refresh the page few times,

Best is to use Firefox, as the errors there appear almost always. The errors appear rarely in other browsers.

image

The first error: The resource from “http://magento.clean/static/version1718361386/frontend/Magento/luma/en_US/mage/common.js” was blocked due to MIME type (“text/html”) mismatch (X-Content-Type-Options: nosniff).

These errors do not occur on magento 2.4.5

I did not test this on magento 2.4.6 so it may be that the issue also occurs there.

Expected result

There are no errors in console. The files are not loaded twice. Only minified files are loaded.

Actual result

There are errors in console. Files are loaded twice .min files & their corresponding 'not minified' are being requested (which fails to load as not minified files, don't exists in pub directory after setup:static-content:deploy) .

image

image

Additional information

I noticed the issue when upgrading from 2.4.4-p8 to 2.4.7 so not quite sure if this started to happen with 2.4.7 release or 2.4.6

Release note

No response

Triage and priority

m2-assistant[bot] commented 1 month ago

Hi @KrzysztofWisniewskiAcc. Thank you for your report. To speed up processing of this issue, make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:

m2-assistant[bot] commented 4 weeks ago

Hi @engcom-Delta. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

engcom-Delta commented 4 weeks ago

Hi @KrzysztofWisniewskiAcc ,

Verified the issue on 2.4.7 community and commerce edition and we are not able to reproduce this issue.

Steps to reproduce:-

1.Enable js minification 2.Run bin/magento setup:upgrade bin/magento deploy:mode:set production 3.Go to front and open the console, check errors 4.Refresh the page few times

For magento community

Screenshot 2024-06-18 at 5 28 45 PM Screenshot 2024-06-18 at 5 29 00 PM Screenshot 2024-06-18 at 5 29 23 PM Screenshot 2024-06-18 at 5 29 54 PM Screenshot 2024-06-18 at 5 30 04 PM

For magento commerce

Screenshot 2024-06-18 at 6 05 45 PM Screenshot 2024-06-18 at 6 05 56 PM

Please refer the attached screenshots and let us know if we missed anything.

KrzysztofWisniewskiAcc commented 3 weeks ago

Hi @KrzysztofWisniewskiAcc ,

Verified the issue on 2.4.7 community and commerce edition and we are not able to reproduce this issue.

Steps to reproduce:-

1.Enable js minification 2.Run bin/magento setup:upgrade bin/magento deploy:mode:set production 3.Go to front and open the console, check errors 4.Refresh the page few times

For magento community

...

I was able to reproduce the issue in the way you described. When I checked 'disable cache' in firefox, after few refreshes I was able to reproduce it. It was more rare to encounter the issue if 'disable cache' was not checked.

image

2 3

engcom-Delta commented 3 weeks ago

Hi @KrzysztofWisniewskiAcc ,

We Verified the issue on 2.4.7 and 2.4-develop again and we are not able to reproduce this.

Steps to reproduce:-

1.Enable js minification 2.Run bin/magento setup:upgrade bin/magento deploy:mode:set production 3.Go to front and open the console, check errors 4.Disable cache 5.Refresh the page few times

For 2.4.7

Screenshot 2024-06-24 at 7 59 28 PM Screenshot 2024-06-24 at 7 59 28 PM

For 2.4-develop

Screenshot 2024-06-24 at 7 59 34 PM Screenshot 2024-06-24 at 7 59 34 PM
engcom-Bravo commented 1 week ago

Hi @KrzysztofWisniewskiAcc,

We have noticed that this issue has not been updated since long time.
Hence we assume that this issue is fixed now, so we are closing it. Please feel to raise a fresh ticket or reopen this ticket if you need more assistance on this.

Thanks.