Message: Your script exceeded the memory limit.
Help with this please. I am not sure what the problem is. Thanks!
Main issue: Multiple merchants are seeing “MemoryQuotaExceeded” (and “unable to debug because the cart was too large”) on Shopify Scripts, including scripts that previously ran fine (e.g., before BFCM). Some report a sudden spike in the last 24 hours while conversions remain unaffected.
Technical context: Script Editor is the legacy tool for checkout scripts; Checkout Extensibility is Shopify’s newer checkout framework. BFCM = Black Friday Cyber Monday.
Proposed causes:
Counterpoints/clarifications:
Actions suggested:
Status: Unresolved. Conflicting reports on root cause; screenshots of code/errors are central.
Message: Your script exceeded the memory limit.
Help with this please. I am not sure what the problem is. Thanks!
We are getting this same error on one of our scripts and I’m not sure what the problem is.
Experiencing the same. Running the same script we did before BFCM (which had no errors) - seeing this memory error now but when I try to debug, none of the production errors show.
Seeing the same thing for the last 24 hours. Crazy spike. But conversion rates are holding just fine.
If I’m reading this code correctly, you are looping through all the items in the cart three times. I recommend refactoring this code to make one loop and handle the conditionals inside the loop.
I did my best to type out how you could refactor this, but since your example is an image instead of text, please check for typos or syntax issues before replacing your existing code.
Input.cart.line_items.each do |line_item|
product = line_item.variant.product
next if product.gift_card?
if!Input.cart.customer.nil?
if Input.cart.customer.tags.include?('Wholesale')
line_item.change_line_price(line_item.line_price * 0.42, message: "Wholesale")
end
if Input.cart.customer.tags.include?('Non-Showroom Wholesale')
line_item.change_line_price(line_item.line_price * 0.42, message: "Wholesale Discount")
end
if Input.cart.customer.tags.include?('MAP')
line_item.change_line_price(line_item.line_price * 0.42, message: "MAP Discount")
end
end
end
Hi, we’ve been having the same issue. Also, seeing the message “unable to debug because the cart was too large” when hovering over the exclamation sign. Has anyone figured this out?
By the way we’ve completely re-written the script with the same outcome.
Shopify’s Partner Support responded this:
The "MemoryQuotaExceeded" error is not script code related
It is caused by bots trying to checkout.
Something we cannot stop from our end, but you can by either upgrading your checkout or adding a bot blocker.
When you upgrade to Checkout Extensibility on Shopify, you enable a feature that enhances bot protection in your Checkout settings. This means that the system can identify and block known bots that may be attempting to make automated purchases on your website.
By slowing down bot activity, the feature creates a more level playing field for genuine customers, increasing their chances of successfully completing purchases without interference from malicious bots.
But, if you are to upgrade to extensibility, your scripts will no longer be available.
And they confirmed it was safe to ignore it.
Thats not quite true, Script Editor is being sunset first next year so they will continue to function after the checkout has been upgraded. I first started noticing this error after we upgraded the checkout, prior to that we had no issues with the script.