Skip to content
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

jquery.cookie dependency leads to JS issues with KO dependencies #35913

Closed
1 of 5 tasks
sidolov opened this issue Aug 11, 2022 · 12 comments
Closed
1 of 5 tasks

jquery.cookie dependency leads to JS issues with KO dependencies #35913

sidolov opened this issue Aug 11, 2022 · 12 comments
Labels
Area: Framework Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. Progress: done Reported on 2.4.5 Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch

Comments

@sidolov
Copy link
Contributor

sidolov commented Aug 11, 2022

Preconditions and environment

  • 2.4.5

Steps to reproduce

From Twitter:

https://twitter.com/jissereitsma/status/1557372818257485834
I'm not getting this entirely yet, but a custom #magento 2.4.5 install had a theme with a global Require dep for "jquery/jquery.cookie": This suddenly caused all of the other JS (like KO) to fail silently.

https://twitter.com/jissereitsma/status/1557391198863638530
My theme had a requirejs-config.js with a global "dep" for "jquery/jquery.cookie". Simply because of that, an add-to-cart was not weird: The AJAX call towards the addtocart URL worked fine, with a valid reply. But then the customerData AJAX call was never made ... :o I'm baffled

https://twitter.com/vovayatsyuk/status/1557399058435686400
Looks like Magento can't load the same dependency using different names. You load 'js-cookie/cookie-wrapper' with 'jquery/jquery.cookie' alias, while magento load the same file using 'js-cookie/cookie-wrapper' string.
Can be fixed at https://github.com/magento/magento2/blob/2.4-develop/lib/web/js-storage/js.storage.js#L17

@jissereitsma , @vovayatsyuk please, add additional information if I missed something

Expected result

It's possible to use aliases for jquery/jquery.cookie

Actual result

Issue caused all of the other JS (like KO) to fail silently.

Additional information

No response

Release note

No response

Triage and priority

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.
@m2-assistant
Copy link

m2-assistant bot commented Aug 11, 2022

Hi @sidolov. Thank you for your report.
To speed up processing of this issue, make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

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:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, review the Magento Contributor Assistant documentation.

Add a comment to assign the issue: @magento I am working on this

To learn more about issue processing workflow, refer to the Code Contributions.


⚠️ According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

🕙 You can find the schedule on the Magento Community Calendar page.

📞 The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.

✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

@m2-community-project m2-community-project bot added this to Ready for Confirmation in Issue Confirmation and Triage Board Aug 11, 2022
@sidolov sidolov added Area: Content Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed labels Aug 11, 2022
@m2-community-project m2-community-project bot moved this from Ready for Confirmation to Confirmed in Issue Confirmation and Triage Board Aug 11, 2022
@sidolov sidolov removed the Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed label Aug 11, 2022
@m2-community-project m2-community-project bot moved this from Confirmed to Ready for Confirmation in Issue Confirmation and Triage Board Aug 11, 2022
@sidolov sidolov added the Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed label Aug 11, 2022
@m2-community-project m2-community-project bot moved this from Ready for Confirmation to Confirmed in Issue Confirmation and Triage Board Aug 11, 2022
@github-jira-sync-bot github-jira-sync-bot removed the Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed label Aug 11, 2022
@m2-community-project m2-community-project bot moved this from Confirmed to Ready for Confirmation in Issue Confirmation and Triage Board Aug 11, 2022
@sidolov sidolov added Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed labels Aug 11, 2022
@m2-community-project m2-community-project bot moved this from Ready for Confirmation to Confirmed in Issue Confirmation and Triage Board Aug 11, 2022
@github-jira-sync-bot github-jira-sync-bot removed the Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed label Aug 11, 2022
@m2-community-project m2-community-project bot added Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed and removed Issue: ready for confirmation labels Aug 11, 2022
@m2-community-project m2-community-project bot moved this from Confirmed to Ready for Confirmation in Issue Confirmation and Triage Board Aug 11, 2022
@github-jira-sync-bot github-jira-sync-bot removed the Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed label Aug 11, 2022
@sidolov sidolov added the Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed label Aug 11, 2022
@m2-community-project m2-community-project bot moved this from Ready for Confirmation to Confirmed in Issue Confirmation and Triage Board Aug 11, 2022
@m2-community-project m2-community-project bot added this to Ready for Development in High Priority Backlog Aug 11, 2022
@magento magento deleted a comment from github-jira-sync-bot Aug 11, 2022
@magento magento deleted a comment from github-jira-sync-bot Aug 11, 2022
@magento magento deleted a comment from github-jira-sync-bot Aug 11, 2022
@magento magento deleted a comment from github-jira-sync-bot Aug 11, 2022
@magento magento deleted a comment from github-jira-sync-bot Aug 11, 2022
@magento magento deleted a comment from github-jira-sync-bot Aug 11, 2022
@magento magento deleted a comment from github-jira-sync-bot Aug 11, 2022
@magento magento deleted a comment from github-jira-sync-bot Aug 11, 2022
@magento magento deleted a comment from github-jira-sync-bot Aug 11, 2022
@magento magento deleted a comment from github-jira-sync-bot Aug 11, 2022
@m2-community-project m2-community-project bot moved this from Ready for Development to Dev In Progress in High Priority Backlog Aug 12, 2022
@github-jira-sync-bot github-jira-sync-bot added Progress: PR Created Indicates that Pull Request has been created to fix issue and removed Progress: dev in progress labels Aug 12, 2022
@xmav
Copy link
Contributor

xmav commented Aug 12, 2022

Hello @jissereitsma
Could you please check if that patch resolve issue for you ?

---
 lib/web/jquery/jquery.cookie.js                       | 11 +++++++++++
 lib/web/js-storage/js.storage.js                      |  2 +-
 .../module-theme/view/base/requirejs-config.js        |  1 -
 3 files changed, 12 insertions(+), 2 deletions(-)
 create mode 100644 lib/web/jquery/jquery.cookie.js

diff --git a/lib/web/jquery/jquery.cookie.js b/lib/web/jquery/jquery.cookie.js
new file mode 100644
index 000000000..5268ae4ea
--- /dev/null
+++ b/lib/web/jquery/jquery.cookie.js
@@ -0,0 +1,11 @@
+/**
+ * Copyright © Magento, Inc. All rights reserved.
+ * See COPYING.txt for license details.
+ */
+
+define([
+    'jquery',
+    'js-cookie/cookie-wrapper'
+], function () {
+
+});
diff --git a/lib/web/js-storage/js.storage.js b/lib/web/js-storage/js.storage.js
index b016fc0aa..0ac802854 100644
--- a/lib/web/js-storage/js.storage.js
+++ b/lib/web/js-storage/js.storage.js
@@ -14,7 +14,7 @@
 (function (factory) {
     var registeredInModuleLoader = false;
     if (typeof define === 'function' && define.amd) {
-        define(['jquery', 'js-cookie/cookie-wrapper'], factory);
+        define(['jquery', 'jquery/jquery.cookie'], factory);
         registeredInModuleLoader = true;
     }
     if (typeof exports === 'object') {
diff --git a/vendor/magento/module-theme/view/base/requirejs-config.js b/vendor/magento/module-theme/view/base/requirejs-config.js
index 06e17f76d..911ff329d 100644
--- a/vendor/magento/module-theme/view/base/requirejs-config.js
+++ b/vendor/magento/module-theme/view/base/requirejs-config.js
@@ -68,7 +68,6 @@ var config = {
         'jquery/validate': 'jquery/jquery.validate',
         'jquery/file-uploader': 'jquery/fileUploader/jquery.fileuploader',
         'prototype': 'legacy-build.min',
-        'jquery/jquery.cookie': 'js-cookie/cookie-wrapper',
         'jquery/jquery-storageapi': 'js-storage/storage-wrapper',
         'text': 'mage/requirejs/text',
         'domReady': 'requirejs/domReady',
-- 

@khoimm92
Copy link
Contributor

khoimm92 commented Aug 23, 2022

I am also experiencing this. For example, if call jquery.cookie as dependency on the default.xml layout

requirejs([
        'jquery',
        'jquery/jquery.cookie',
    ], function ($) {
});

Then:

  • Header welcome message
  • Minicart
  • Checkout button ...

will not work.
Replace jquery/jquery.cookie by js-cookie/cookie-wrapper can make it work, but it needs to be compatible with Magento below 2.4.5

@m2-community-project m2-community-project bot moved this from Dev In Progress to Done in High Priority Backlog Aug 25, 2022
@m2-community-project m2-community-project bot removed the Progress: PR Created Indicates that Pull Request has been created to fix issue label Aug 25, 2022
@andrewbess
Copy link
Contributor

Hello @khoimm92
The provided fix resolves problem described by you.
We checked it.
Thank you for your collaboration

@jissereitsma
Copy link
Contributor

jissereitsma commented Aug 26, 2022

@xmav Sorry for the delay. As mentioned on twitter, I actually fixed the issue for myself earlier. But I tested out things out, and indeed the fix is good! Many thanks! Also thanks @sidolov @vovayatsyuk for helping along with this.

@ghost
Copy link

ghost commented Sep 1, 2022

Hello @jissereitsma Could you please check if that patch resolve issue for you ?

---
 lib/web/jquery/jquery.cookie.js                       | 11 +++++++++++
 lib/web/js-storage/js.storage.js                      |  2 +-
 .../module-theme/view/base/requirejs-config.js        |  1 -
 3 files changed, 12 insertions(+), 2 deletions(-)
 create mode 100644 lib/web/jquery/jquery.cookie.js

diff --git a/lib/web/jquery/jquery.cookie.js b/lib/web/jquery/jquery.cookie.js
new file mode 100644
index 000000000..5268ae4ea
--- /dev/null
+++ b/lib/web/jquery/jquery.cookie.js
@@ -0,0 +1,11 @@
+/**
+ * Copyright © Magento, Inc. All rights reserved.
+ * See COPYING.txt for license details.
+ */
+
+define([
+    'jquery',
+    'js-cookie/cookie-wrapper'
+], function () {
+
+});
diff --git a/lib/web/js-storage/js.storage.js b/lib/web/js-storage/js.storage.js
index b016fc0aa..0ac802854 100644
--- a/lib/web/js-storage/js.storage.js
+++ b/lib/web/js-storage/js.storage.js
@@ -14,7 +14,7 @@
 (function (factory) {
     var registeredInModuleLoader = false;
     if (typeof define === 'function' && define.amd) {
-        define(['jquery', 'js-cookie/cookie-wrapper'], factory);
+        define(['jquery', 'jquery/jquery.cookie'], factory);
         registeredInModuleLoader = true;
     }
     if (typeof exports === 'object') {
diff --git a/vendor/magento/module-theme/view/base/requirejs-config.js b/vendor/magento/module-theme/view/base/requirejs-config.js
index 06e17f76d..911ff329d 100644
--- a/vendor/magento/module-theme/view/base/requirejs-config.js
+++ b/vendor/magento/module-theme/view/base/requirejs-config.js
@@ -68,7 +68,6 @@ var config = {
         'jquery/validate': 'jquery/jquery.validate',
         'jquery/file-uploader': 'jquery/fileUploader/jquery.fileuploader',
         'prototype': 'legacy-build.min',
-        'jquery/jquery.cookie': 'js-cookie/cookie-wrapper',
         'jquery/jquery-storageapi': 'js-storage/storage-wrapper',
         'text': 'mage/requirejs/text',
         'domReady': 'requirejs/domReady',
-- 

Working fine for me!

@ghost
Copy link

ghost commented Sep 1, 2022

bc2b48a

@shikharainabounteous
Copy link

Is this patch released? I am facing this issue on ver. 2.4.5-p1 also.

@Keivanph
Copy link

That patch fixed my issue on M2.4.5-p2
tnx.
I had similar issue, the proceed to checkout button was not working. Add to cart was not showing any notifications that a product is added to a cart.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Framework Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. Progress: done Reported on 2.4.5 Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch
Projects
Development

No branches or pull requests

9 participants