json error help needed

Solved
Highlighted
New Member
4 0 0

We're getting the following error on our store:

 

Oops! Something went wrong. Please try again... TypeError: Failed to execute 'json' on 'Response': body stream is locked shopify

 

It happens when a product is being added to cart (website: https://lxmi.com). Our developers can't seem to figure it out and I contacted Shopify support and they couldn't seem to help. I looked at the account activity and the only thing that happened yesterday was the Free Gifts by Secomapp made changes, but I'm not sure what. I've gone through and removed the app and tried to remove all the code from that and the error still doesn't seem to go away. 

 

Any help would be very appreciated. 

 

Thanks!

 

0 Likes

Success.

Shopify Partner
798 75 111

The issue is that the response of the call to /cart/add.js is being processed twice, ie. .json() is called on the Response object twice. When that happens the second time, it fails with the error saying that the Response has been read once and is now locked.

 

The first time .json() is called after 'addItem' method somewhere within 'click' handler under template.product.js which then fires 'build' event which is handled by document.addEventListener("build",...) function within 'panel-cart' module in layout.theme.js which calls 'updateCart' method which is trying to execute .json() the second time.

 

Hope that helps your developer, it is very hard to follow the flow without having the code at hand. All this above is just what I see while debugging the store using developer tools.

 

 

Sergiu Svinarciuc | CTO @ visely.io
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
- To learn more about the awesome stuff we do head over to visely.io or our blog
1 Like
New Member
4 0 0

Thanks! Our developers were able to fix it. I really appreciate the help. 

0 Likes