TimeQuotaExceeded shopify script error Production Error

17 2 6


     I have been running a script to discount all vip members giving a discount and the script was published in the June and till now it was running fine and suddenly yesterday I got an production error saying 

TimeQuotaExceeded  - Message: Your script exceeded the time limit.
Checked the code and couldn't find any errors in the script and script seems to work fine with the more products as well. The order on which it failed seems to have just one cart item. Cant find an error and would like to know what is causing this error and how to overcome it ? I am pasting the code for the reference and appreciate your time and efforts for looking into this.


# If the customer is a VIP member, give them a discount on all items

if !Input.cart.customer.nil? 
  Input.cart.customer.tags.each do |tag|
    if tag.start_with?('Discount: ')
      DISCOUNT_PERCENT = (tag.split('%').first).split(' ').last.to_i / 100
      DISCOUNT_MESSAGE = tag.split(': ').last + ' OFF'

  if Input.cart.discount_code
      message: "Discounts can not be used with your everyday discount."
  Input.cart.line_items.each do |line_item|
    if !line_item.variant.compare_at_price.nil? 
      if (line_item.variant.compare_at_price * line_item.quantity * (1-DISCOUNT_PERCENT)) <= line_item.line_price
        line_item.change_line_price(line_item.variant.compare_at_price * line_item.quantity * (1-DISCOUNT_PERCENT),message: DISCOUNT_MESSAGE)
        new_properties = line_item.properties
        new_properties.merge!({"_discount_note" => DISCOUNT_MESSAGE})
        line_item.change_properties(new_properties, message: "")
        new_properties = line_item.properties
        new_properties.merge!({"_discount_note" => "Sale price less than discount"})
        line_item.change_properties(new_properties, message: "")
      line_item.change_line_price(line_item.line_price * (1-DISCOUNT_PERCENT), message: DISCOUNT_MESSAGE)
      new_properties = line_item.properties
      new_properties.merge!({"_discount_note" => DISCOUNT_MESSAGE})
      line_item.change_properties(new_properties, message: "")

Output.cart = Input.cart


Let me know of any possible solutions and the way to handle it.
Replies 5 (5)
Shopify Expert
11159 222 2274

You have code in place that is nth scaling. One you have something that loops over customer tags, and the other that loops over all the items in the cart.So I could see how a customer will lots or tags - or a larger cart - could push you closer to the existing limits.

  • Do you need those loops?
  • Have you tested your code on larger carts, or with customers with many tags?

I would like to see you use two tags since it looks like you're using a tag to drive a discount. A customer (that knows how) could add tags to their own account so you're opening yourself to some risk here. A second tag would give you added security, and make it harder for someone to guess what it is. Would strongly recommended you don't post the shop url here if you are not going to change that.

★ I jump on these forums in my free time to help and share some insights. Not looking to be hired, and not looking for work. http://freakdesign.com.au ★
10 0 11

This is happening for us as well.  And has been posted here: https://community.shopify.com/c/Script-Editor/Suddenly-got-production-error-TimeQuotaExceeded/td-p/4...

We have scripts that are very basic being applied to checkouts with only 1 item where this is occurring.  Debug in editor shows 0% cpu and 6% memory.  Randomly happened 5x today.

I have emailed our Shopify rep and I ll try to post here if there is any resolution.

17 2 6

Hi Johanson, 

    The reason shopify support suggested me was this time quota error occurs if the shopify's server does not recieve the response from the client side. They have set up the server timeout for the scripts to run which i forgot what was the actual number but if it falls out of range then this error is triggered and is happens very random and after certain period of time. I let the front end team to look forward to my scripts as that was in place for atleast one year and they said it is fine and to ignore this error. 

Looking at your response seems like you have ran into similar issue with us where they dont have any resolution but if you came across a lot of issues then let the technical support to review your script and that way you might be able to find out the resolution.

3 0 0

I assume a similar issue would cause this:


MemoryQuotaExceeded: Your script exceeded the memory limit.


We are getting that on a script we have. What's odd is that we have 2 stores, and on both im using the exact same script. Only one has been throwing this error, and the other one not once. And the scripts are a copy paste of each other.

Very confused as to why its happening because i when i changed the script this week, I actually removed content, but before it wasnt giving the Memory error.

Shopify Partner
13 0 6

I've just started seeing this error for a script that I've been running for over a year. Mine is a Free Shipping with Discount Code script...needed because we still want discounts codes to apply and give everyone using a specific code Free Shipping.


I'm ignoring it for now as I haven't seen the script actually stop working...not sure if any action is actually necessary her though. 

Kyle Moloo | Sr. Director of Ecommerce