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.
Solved! Go to the solution
This is an accepted solution.
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.