magento2: JS error in the customer data
Originally this issue was reported in https://github.com/magento/magento2/commit/5983e1733d56b1b2f15fb4f0e64094a3a4f3145d#commitcomment-44080850 by @HenKun.
The following commit https://github.com/magento/magento2/commit/5983e1733d56b1b2f15fb4f0e64094a3a4f3145d leads to similar issues described in https://github.com/magento/magento2/pull/24847.
Preconditions (*)
- Magento 2.4.1, or 2.4-develop
Steps to reproduce (*)
- Add the following code to the page on frontend:
<script>
require(['Magento_Customer/js/customer-data'], function (customerData) {
console.log(customerData.getExpiredSectionNames());
});
</script>
- Go to the frontend, see the console
Expected result (*)
- In the console you should see an empty array, like this:

Actual result (*)
- in the console we see the following error:

Additional info from Engcom
Add the script to, for example, /app/code/Magento/Customer/view/frontend/templates/form/edit.phtml

- In the Storefront, Sign In as a Customer
- Go to My Account
- Click Edit under Contact Information
- Observe the dev console
Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.
- 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”.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 6
- Comments: 20 (10 by maintainers)
Commits related to this issue
- MC-36096: [Cloud] Local cache storage is not retained for the expected period. — committed to magento/magento2 by tsviklinskyi 4 years ago
- Merged PR 29368: Remove invalidate function to skip js error ## What's being changed We're removing the `invalidate` call prior to refreshing the section in the stored customerData, in our chatData.... — committed to dotmailer/dotmailer-magento2-extension-chat by sertlab 3 years ago
- cookie expiration date is not updated after Cookie Lifetime is changed — committed to magento/magento2 by glo05363 3 years ago
@gkopec The fix for this issue was accidentally removed in magento 2.4.4 and 2.4.5. I’ve created a pull request for that: https://github.com/magento/magento2/pull/36177
You can use this patch for 2.4.5: https://github.com/magento/magento2/commit/847c7997143d3c90b26f94480a9fe202f499faf7.diff
@gabrieldagama The fix didn’t merge into 2.4.3 yet, so it does not available in 2.4.3
After this was fixed, the fix was removed by this commit: https://github.com/magento/magento2/commit/405ee6ebdfb9a3df7455153eb11af2f91fdba562
So in version 2.4.5 the bug is back again… 🤦🏻♂️
up, 2.4.x-develop seems to still produce the error (tested with firefox).
Re-opened since it was reverted. https://github.com/magento/magento2/issues/31920#issuecomment-1253711103
@gkopec, I created this from the PR:
@ihor-sviziev yep I see it.
Thanks