-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JS Minification issue & requirejs loading in production mode in 2.4.7 #38829
Comments
Hi @KrzysztofWisniewskiAcc. Thank you for your report.
Join Magento Community Engineering Slack and ask your questions in #github channel. |
Hi @engcom-Delta. Thank you for working on this issue.
|
... I was able to reproduce the issue in the way you described. |
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. |
We are experiencing the same issues after upgrading from version 2.4.6 to 2.4.7-p1. @KrzysztofWisniewskiAcc, have you managed to resolve this problem? |
I have the same issue; and also have the same problem creating a 100% reproducible case. Not sure how exactly; But I think this is happening when caches are expired and/or recompiling on that specific request - possibly enforced by the Sorry I have nothing decent to add to re-open this ticket. |
Did anyone find a solution? I have the same problem with 2.4.7-p1 but on mobile view only. In desktop, only minified js files are loaded by the browser. But in mobile view, it tries to load both minified and unminified js files in production mode with minify js turned on. |
I was not able to solve the issue, Not sure on what layer is it lying, is there some kind of external dependency that is pulled and tries to load things different way or was the loading mechanism messed? |
I was able to resolve it, though I don't know how it resolved it. Normally, I put the site in production mode and let Magento compile and deploy static content. This is how I've always done it. To fix this though, I have to go to production mode, then clear generated, view-preprocessed, deployed version, static content and cache then while in production mode I compile code, force static content deployment and this resolved the issue. Again, I don't know why setting production mode is different than a manual di compile and content deploy, but it makes the difference on my site. |
My live environment is on Magento 2.4.6-p7 and it does not have the problem mentioned here. However, I have recently upgraded my test environment to Magento 2.4.7-p2 and it has this problem. The solution of @tstamplis did not work for me. To be honest I don't see why compiling and creating the static files two consecutive times would solve this problem. |
We are also facing this issue. We recently upgraded our Magento cloud instance from 2.4.6-p5 to 2.4.7-p2 and we can see the minify JS are not loading and it is braking the material icons loading and stopping our checkout process as well. |
We're encountering the same issue as described on our site running 2.4.7-p2. JS is minified but it trieds to load the unminified versions. It doesn't happen every time and seems to happen more often when cache is disabled. It's probably some race condition. Putting breakpoints in requirejs-min-resolver.min.js would help debug the problem but it doesn't happen when the breakpoints are set. This file is responsible for rewritting the url to the minified version so somehow it isn't being executed before the other code. Our site is goodsalt.com. Our build process always manually compiles the static assets before they are deployed. Is there any solution or debug steps we can perform? |
we have the same issue on 2.4.7-p2. I have disabled minification and merge for .js files and the errors have gone we need a fix so we can minify js again |
Same here, 2.4.7-p3. It happens randomly but if I refresh any page a few times then one of them will fail. |
I found changing the .htaccess file in /pub/static by uncommenting |
This seems like a race condition bug. Looking into it, the url is generated in When minification is enabled, Putting breakpoint on it as well as on the require.js (each module is added using I guess temporary fixes could be patching the require.js file to contain the minify logic, but not sure how to know if minify is enabled or not. Or adding an apache/nginx rule to append the min.js on 404s. I am using magepack for bundling but even without it the problem appears although less often. |
I found the errors always showed in the console on the Firefox browser, and Chrome was a bit hit-and-miss. the errors were also more obvious in the admin, but as I said, the errors went away after changing the .htaccess file as I mentioned earlier |
have the same issue |
The old mixins.js file from this commit helped me: Try it yourselves to see if it helps you. |
This issue is not fixed. Reopening. |
Hi @KrzysztofWisniewskiAcc @VitaliyBoyko , We Verified the issue on 2.4.7-p3 and we are not able to reproduce this. Steps to reproduce:- 1.Enable js minification Can you please provide additional testing steps. |
@engcom-Delta thank you for looking into this! This issue indeed appears to be tricky to reproduce consistently—a bit of a Heisenbug scenario. The only pattern we've observed is that the system requires particularly fast memory and a high-performance environment to manifest the issue. For instance: On our Magento staging instance, we’ve been unable to reproduce it under normal conditions. Given the reports from multiple users encountering the issue, it’s clear that it does exist. I recommend escalating it to your most experienced JS engineers for further analysis. |
I've noticed the same issue and can reproduce it but as said above, not consistently. When the page produces the error the script tags are put 2x in the DOM: One time with |
We're experiencing the same issue as mentioned in this comment #38829 (comment) after upgrading from 2.4.6-p5 to 2.4.6-p9, but only on
Please, let's keep this discussion going. I've already spent a lot of time on this and happy to buy someone a few coffees for the ultimate advice, no matter how simple it may be. Note: |
@magenizr I didn't fix the issue but just made a workaround to rewrite any not found JS file to location ~ ^(.+)\.(js)$ {
try_files $1.$2 $1.min.$2 $uri =404;
} I don't remember details anymore but I think it is a race condition bug. |
Thanks for your reporting and collaboration. Looking forward to your response. Thanks. |
Hi folks, I finally had some time to dig into it and fixed errors like
Long story short: In my case it was a custom @domeglic @Echron @drabikowy If you follow the same debugging steps, you might get an idea what is missing. |
@magenizr, I followed these steps, but I can't reproduce the output you are getting. The URL remains the absolute URL. I will follow your thought process and continue with debugging the require.js file. I've added a bit logging around the "enable" method for a module. As when enabled the dependencies get loaded as well.
This is the expected data for a module to load:
This is the output of the first module where the map.url does not end with As you see the dependencies are not using the minified version either. In require.js in the method "makeModuleMap", I find that filenames starting with "_@r" are generated: "If no name, then it means it is a require call, generate an internal name.". This is how far I got for now, I'll debug this further and share my findings. |
You can try to edit any category and open Content group, you may see error from console log |
for us, we found it was a cache issue flush js css cache, flush magento cache, flush Cloudflare cache Check the console for errors again |
Hello all, you can try a workaround solution:
|
Preconditions and environment
Steps to reproduce
...
Best is to use Firefox, as the errors there appear almost always.
The errors appear rarely in other browsers.
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) .
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
The text was updated successfully, but these errors were encountered: