Magento2: M2.1.x Random checkout page not loading - JS error customer-data.js:163 or customer-data.min.js

Created on 22 Jun 2017  路  3Comments  路  Source: magento/magento2

Issue description

I get the following error in the console. It doesn't matter if I'm logged in or not:
Uncaught TypeError: Cannot create property 'checkout-data' on string '{"cart":1498083338,"directory-data":1498083338,"zopim-chat":1498083338,"customer":1498083338,"compare-products":1498083338,"last-ordered-items":1498083338,"wishlist":1498083338,"paypal-billing-agreement":1498083338,"messages":1498083338,"review":1498083338}'
at customer-data.js:163

Preconditions

Magento version 2.1.5 in production but also on 2.1.7 in development
Website is hosted with Byte.

Steps to reproduce

In Chrome 58 on Mac (this might be a Mac + Chrome only issue, I did not test on other environments)

  1. Open Chrome
  2. Open Product
  3. Add Product to basket
  4. Go to checkout

Actual Result

At points 2, 3 you could see an error in your console.
At point 4 you will not see the checkout.

The error is random, it can be 5x no error and then all the time..

Expected result

No errors in console and a checkout page which is loading.

Solution

I traced the issue back in vendor/magento/module-customer/view/frontend/web/js/customer-data.js on line 159 data is retrieved from the cookie storage.
This data is sometimes an object and sometimes a string.
This should not be a string, so to make sure it is an object as fix, I added on line 160:
if (typeof sectionDataIds == 'string') sectionDataIds = JSON.parse(sectionDataIds);

Checkout Cannot Reproduce Clear Description Format is valid bug report

All 3 comments

Unfortunately I could not reproduce this issue. We need more information about your configuration to reproduce this issue. Please identify the web server you are running, the versions of PHP and MySQL, and any other information needed to reproduce your issue.

@Tantuss, thank you for your report.
We were not able to reproduce this issue by following the steps you provided. If you'd like to update it, please reopen the issue.
We tested the issue on 2.1.9

I am also getting this issue on 2.1.9. Tantuss code fixed the problem. Please merge this.

Was this page helpful?
0 / 5 - 0 ratings