bigcommerce / stencil-utils

Utility library for the Stencil theme framework.
BSD 4-Clause "Original" or "Old" License
31 stars 43 forks source link

Uncaught (in promise) TypeError: Cannot read property 'physicalItems' of undefined: cart.js:71 #148

Open Mikhail-MM opened 3 years ago

Mikhail-MM commented 3 years ago

Hello,

I've been seeing this error on multiple Cornerstone themes.

This happens on page-load, I assume this is happening when you land on a BC page and have an empty cart, potentially related to the theme checking for the quantity in cart to update the count-pill.

This is the error that shows up in console:

cart.js:71 

Uncaught (in promise) TypeError: Cannot read property 'physicalItems' of undefined
    at cart.js:71
    at cart.js:44
    at request.js:124

Origin of the error is /stencil-utils/src/api/cart.js

Any ideas on how to resolve, is this a problem with a cornerstone version, or stencil utils version, or both?

jairo-bc commented 3 years ago

Hi @Mikhail-MM,

This is currently fixed in https://github.com/bigcommerce/stencil-utils/pull/137. And this will be released with next version 6.7.0 (https://github.com/bigcommerce/stencil-utils/pull/147) of stencil-utils

Mikhail-MM commented 3 years ago

@jairo-bc Thanks for the quick response,

Is this related to this PR in Cornerstone (https://github.com/bigcommerce/cornerstone/pull/1920)?

I've seen some issues on Chrome local development where adding to cart + going to the cart page will result in an empty cart, trying to make sense of why this is happening, I'm worried that there is a de-sync between the CartID returned by Stencil Utils & The CartID injectd by BigCommerce Context

jairo-bc commented 3 years ago

@Mikhail-MM That PR is mostly about cleaning up the cornerstone. The fix is already applied on the cornerstone, it's only requires the newer version of stencil utils that will come up early next week

Mikhail-MM commented 3 years ago

@jairo-bc Do you know which version number of cornerstone/ which Pull Request this was patched in on cornerstone?

We have some older client themes that are running into this and we may need to do some work on our end to avoid issues.

rowleyaj commented 3 years ago

@Mikhail-MM cornerstone will need a new release, after the stencil-utils release is done, before we're able to use this fix.

Mikhail-MM commented 3 years ago

@rowleyaj I see, thank you. I'll keep an eye out on the changelog so that we can merge the updates in selectively.

I'm still trying to find the best way to keep our custom themes in sync with latest cornerstone updates.

Once we begin to work on a theme for a client using a any version of cornerstone our development tends to branch off completely.

We're still trying to find a way to be able to automatically merge critical changes into Cornerstone using GitHub without seeing merge conflicts

jairo-bc commented 3 years ago

@Mikhail-MM stencil-utils 6.7.0 was released to npm.